在网页制作中,在制作管理后台的时候,为了保证安全性,我们经常需要在asp.net中判断链接来源,如果HTML链接来自外部,不属于本站的HTML超文本链接,那我们就禁止操作后台,给出相应提示。在asp.net中判断链接来源的代码如下:
public bool IsUrl()
{
string str1 = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_REFERER"];
string str2 = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
return ((str1 != null) && (str1.IndexOf(str2) == 7));
}
而以前在asp中我们使用如下方法进行判断链接来源
"" then
If Mid(Server_url1,8,len(Server_url2)) Server_url2Then
Response.End
End If
end if
Server_url1=Cstr(Request.ServerVariables("HTTP_REFERER"))
Server_url2=Cstr(Request.ServerVariables("Server_Name"))
if Server_url1"" then
If Mid(Server_url1,8,len(Server_url2)) Server_url2Then
Response.End
End If
end if
%>
在讲述asp.net中判断链接来源的方法外,我们还介绍了在ASP中判断链接来源
asp.net中判断链接来源
最新推荐文章于 2021-08-03 09:36:53 发布