问题描述
protectedvoidButton1_Click(objectsender,EventArgse){stringEdittext=WebEditor1.Text;stringtempnewstitle=Request.Form["newstitle"].Trim();stringtemppublishertel=Request.Form["publishertel"].Trim();stringtemppublisher=Request.Form["publisher"].Trim();mySocut.ExecuteSql("InsertIntoliyang(newstitle,userphone,username,newstext,publishtime)Values('"+tempnewstitle+"','"+temppublishertel+"','"+temppublisher+"','"+Edittext+"','"+DateTime.Now+"')");Response.Write("<script>alert('新增成功!');location.href='rep.aspx';</script>");}
解决方案
解决方案二:
Request.ServerVariables["REMOTE_HOST"]
解决方案三:
....................不明白往我用的里面加好了
解决方案四:
stringsip;try{sip=Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();}catch{sip=Request.ServerVariables["REMOTE_ADDR"].ToString();}
这是最准确的
解决方案五:
顶三楼的
解决方案六:
publicstaticstringGetIPAddress(){stringuser_IP=string.Empty;if(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]!=null){if(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]!=null){user_IP=System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();}else{user_IP=System.Web.HttpContext.Current.Request.UserHostAddress;}}else{user_IP=System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();}returnuser_IP;}
解决方案七:
试试:
解决方案八:
有那么麻烦吗stringuserip=HttpContext.Current.Request.UserHostAddress;