防Post提交
public static bool CheckUrl()
{
Uri ComeUrl = HttpContext.Current.Request.UrlReferrer;
string cUrl;
if (ComeUrl == null)
{ return false; }
else
{
string reffer = ComeUrl.ToString();
cUrl = "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
if (reffer.Substring(cUrl.Length, 1) == ":")
{
cUrl += ":" + HttpContext.Current.Request.ServerVariables["SERVER_PORT"].ToString();
}
int lenth;
lenth = cUrl.Length;
cUrl += HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"];
int result;
result = String.Compare(reffer, 1, cUrl, 1, lenth, true);
return (result == 0);
}
}