怎样防止用户在地址栏直接输入地址来访问我的ASP页面?

来源:百度知道 编辑:UC知道 时间:2024/05/23 14:11:43
最好有完整代码!

<%
'防止直接输入网址
ComeUrl=trim(request.ServerVariables("HTTP_REFERER"))
if ComeUrl="" then
response.write "<p align=center><font color='red'>对不起,为了系统安全,不允许直接输入地址访问本页面</font></p>"
response.end
else
cUrl=trim("http://"; & Request.ServerVariables("SERVER_NAME"))
if ubound(split(ComeUrl,":"))>1 then
cUrl=cUrl & ":" & Request.ServerVariables("SERVER_PORT")
end if
cUrl=cUrl & request.ServerVariables("SCRIPT_NAME")
if lcase(left(ComeUrl,instrrev(ComeUrl,"/")))<>lcase(left(cUrl,instrrev(cUrl,"/"))) then
response.write "<p align=center><font color='red'>对不起,为了系统安全,不允许从外部链接地址访问本页面</font></p>"
response.end
end if
end if
%>

判断来源,如果为空则response.end