public string CheckUrl()
{
Uri ComeUrl = HttpContext.Current.Request.UrlReferrer;
string cUrl = string.Empty;
HttpContext context = HttpContext.Current;
if (context.Request.Browser.Browser.ToLower() == "unknown")
{
return "浏览器未知!";
}
if (context.Request.Browser.Platform.ToLower() == "unknown")
{
return "操作系统未知!";
}
if (context.Request.HttpMethod.ToUpper() != "POST")
{
return "提交错误!";
}
if (ComeUrl == null)
{
return "请从UrL访问!";
}
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);
if (result != 0)
{
return "请从请从正确UrL访问!";
}
}
return "";
}