»ñÈ¡ÕæʵIPºÍ´úÀíIP (asp.net C#)
³ÌÐò´úÂë
public static string GetRealIP()
{
string ip;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
}
else
{
ip = request.UserHostAddress;
}
}
catch (Exception e)
{
throw e;
}
return ip;
}
»ñÈ¡´úÀíIP
³ÌÐò´úÂë
public static string GetViaIP()
{
string viaIp = null;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
viaIp = request.UserHostAddress;
}
}
catch (Exception e)
{
throw e;
}
return viaIp;
}
Ïà¹ØÎĵµ£º
¼´Ê¹ÎÒ½«Êý¾Ý¿â·ÅÔÚÏîÄ¿ÄÚ½¨µÄÎļþ¼ÐdbÏ£¬¿ÉÊǽøÐд洢²Ù×÷µÄʱºò£¬Êý¾Ý±íûÓÐÈκα仯¡£ºóÀ´·¢ÏÖ´¢´æ¸Ä±ä·¢ÉúÔÚbin\\debug\\dbĿ¼ÏµÄÊý¾Ý¿âÖУ¬Õâ¸öÊý¾Ý¿âÊÇÔÚ³ÌÐòÔËÐÐʱ×Ô¶¯¸´ÖƹýÈ¥µÄ£¬¿ÉÊÇΪʲô´æ´¢±ä»¯Ã»Óз´Ó¦µ½ÍâÃæÏîÄ¿ÄÚµÄÊý¾Ý¿âdbÏÂÄØ£¿ÎÒÏëÁ¬½Ó×Ö·û´®ÖÐdatasourceÖеÄdatadirectory´æÔÚһЩÐþ»ú£¬ÓÚÊÇÎÒÕÒµ½Ò ......
Ê×Ò³£º
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head ......
public static void Main()
{
WebRequest req = WebRequest.Create("http://blog.csdn.net/xiaofengsheng");
try
& ......
Ò»¡¢ÏÂÔØ dotnetfx.exe °²×°
¶þ¡¢×¢²áasp.net C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i
Èý¡¢ÐÞ¸ÄASPXÀ©Õ¹Ö¸Ïò C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
Æô¶¯Õ¾µã ¾Í¿ÉÒÔÁË ......
ASP.NET C# Éú³É¾²Ì¬Ò³Ãæ¼òµ¥·½·¨
//Ô´ÂëÊÇÌæ»»µôÄ£°åÖеÄÌØÕ÷×Ö·û
string mbPath = Server.MapPath("template.html");
Encoding cod ......