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

最好有完整代码!...
2026年09月26日 18:49
有2个网友回答
网友(1):

<%
'防止直接输入网址
ComeUrl=trim(request.ServerVariables("HTTP_REFERER"))
if ComeUrl="" then
response.write "

对不起,为了系统安全,不允许直接输入地址访问本页面

"
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 "

对不起,为了系统安全,不允许从外部链接地址访问本页面

"
response.end
end if
end if
%>

网友(2):

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