ASP.NET»ñÈ¡¿Í»§¶ËIP/Óû§ÃûµÈÐÅÏ¢
1. ÔÚASP.NETÖÐרÓÃÊôÐÔ£º
»ñÈ¡·þÎñÆ÷µçÄÔÃû£ºPage.Server.ManchineName
»ñÈ¡Óû§ÐÅÏ¢£ºPage.User
»ñÈ¡¿Í»§¶ËµçÄÔÃû£ºPage.Request.UserHostName
»ñÈ¡¿Í»§¶ËµçÄÔIP£ºPage.Request.UserHostAddress
2. ÔÚÍøÂç±à³ÌÖеÄͨÓ÷½·¨£º
»ñÈ¡µ±Ç°µçÄÔÃû£ºstatic System.Net.Dns.GetHostName()
¸ù¾ÝµçÄÔÃûÈ¡³öÈ«²¿IPµØÖ·£ºstatic System.Net.Dns.Resolve(µçÄÔÃû).AddressList
Ò²¿É¸ù¾ÝIPµØÖ·È¡³öµçÄÔÃû£ºstatic System.Net.Dns.Resolve(IPµØÖ·).HostName
3. ϵͳ»·¾³ÀàµÄͨÓÃÊôÐÔ£º
µ±Ç°µçÄÔÃû£ºstatic System.Environment.MachineName
µ±Ç°µçÄÔËùÊôÍøÓò£ºstatic System.Environment.UserDomainName
µ±Ç°µçÄÔÓû§£ºstatic System.Environment.UserName
4. if(Request.ServerVariables["HTTP_VIA"]!=null){ string user_IP=Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}else{
string user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString();
}
5.<%=Request.UserHostAddress%>
6.»ñÈ¡¿Í»§¶ËIP:
private string GetClientIP()
{
string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.UserHostAddress;
}
return result;
}
»ñÈ¡MACµØÖ·:
[DllImport("Iphlpapi.dll")]
private static extern int SendARP(Int32 dest,Int32 host,ref Int64 mac,ref Int32 length);
[DllImport("Ws2_32.dll")]
private static extern Int32 inet_addr(string ip);
private void Page_Load(object sender, System.EventArgs e)
{
// ÔÚ´Ë´¦·ÅÖÃÓû§´úÂëÒÔ³õʼ»¯Ò³Ãæ
try
{
Ïà¹ØÎĵµ£º
¼¸ÖÖUpdatePanel¿Ø¼þµÄ×î¼òµ¥µÄÓ÷¨.
1.ÔÚUpdatePanel¿Ø¼þÀíµÄ×ӿؼþÖ±½Ó¾Ö²¿Ë¢ÐÂÄÚÈÝ.
Ó÷¨ÈçÏÂ
Ê×ÏȱØÐëÏÈÍÐÒ»¸öScriptManager¿Ø¼þ·ÅÔÚÒ³ÃæÄÚ,
ÔÚÍÐÒ»¸öupdatePanel¿Ø¼þ
ÔÚContentTemplateÀïÃæ·ÅҪˢеÄÄÚÈݺͰ´Å¥,
½«updatePanelµÄUpdateMode="Conditional",
ÕâÑù°´Å¥Ê¼þ½«ÔÚ¾Ö²¿Ë¢Ð¿ؼþÀïÃæµÄÄÚÈ ......
×ܽá³öÒÔϼ¸¸ö´«µÝ²ÎÊýµÄ·½·¨£º
µÚÒ»ÖÖ·½·¨£º
ͨ¹ýURLÁ´½ÓµØÖ·´«µÝ
send.aspx:
protected void Button1_Click(object sender, EventArgs e)
{
Request.Redirect("Default2.aspx?username=honge");
}
receive.aspx:
s ......
ÔÚ½øÐÐASP.NETµ÷ÊÔµÄʱºò£¬ÎÒÃǾ³£ÐèÒª½èÖúһЩÍⲿ¹¤¾ßÀ´¸¨ÖúÎÒÃÇ¡£Ë×»°Ëµ£¬¹¤ÓûÉÆÆäÊ ±ØÏÈÀûÆäÆ÷¡£¿É±ðС¿´ÁËÕâЩ¹¤¾ß£¬ËüÊÇÄã½â¾ö¸´ÔÓÎÊÌâµÄ±Ø±¸ÀûÆ÷¡£±È½Ï³£ÓõÄÓÐÕâЩ£º
HTTP×¥°ü¹¤¾ß£º Microsoft Network Monitor£¬Fiddler2£¬HttpWatcher µÈ£¬Ö÷ÒªÓÃÀ´²é¿´HTTPÏûÏ¢µÄheader£¬ÒÔ¼°body¡£ http://www.mscto.com
´ ......
¡ï1. ʹÓÃQueryString±äÁ¿
¡¡¡¡¡¡QueryStringÊÇÒ»Öַdz£¼òµ¥µÄ´«Öµ·½Ê½£¬Ëû¿ÉÒÔ½«´«Ë͵ÄÖµÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸ÖС£Èç¹ûÊÇ´«µÝÒ»¸ö»ò¶à¸ö°²È«ÐÔÒªÇ󲻸߻òÊǽṹ¼òµ¥µÄÊýֵʱ£¬¿ÉÒÔʹÓÃÕâ¸ö·½·¨¡£µ«ÊǶÔÓÚ´«µÝÊý×é»ò¶ÔÏóµÄ»°£¬¾Í²»ÄÜÓÃÕâ¸ö·½·¨ÁË¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£º
a.aspxµÄC#´úÂë
private void B ......
ASP.NET³£ÓõÄ6ÖÖÑéÖ¤¿Ø¼þ£¬ÈçÏ£º
RequiredFieldValidator £¨±ØÐë×Ö¶ÎÑéÖ¤£© ÓÃÓÚ¼ì²éÊÇ·ñÓÐÊäÈëÖµ
CompareValidator £¨±È½ÏÑéÖ¤£© °´É趨±È½ÏÁ½¸öÊäÈë
RangeValidator £¨·¶Î§ÑéÖ¤£© ÊäÈëÊÇ·ñÔÚÖ¸¶¨·¶Î§
RegularExpressionValidator £¨Õ ......