Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can ASP raise HTTP errors?

Status
Not open for further replies.

Nevermoor

Programmer
Jul 25, 2003
218
US
Hi, I've been looking all over google, and I can't seem to find either a yes or no to this question.

Basically, I have an admin suite built into an ASP page and would love to do something like:
Code:
if not IsAdmin(user) then
    raise HTTP Error 401.5
else
    display page
end if

with the idea being that IIS would catch the HTTP Error and display the 401.5 error file registered for that folder.

The code is only an issue for a non-admin user who enters in the full url or an admin whose session has expired because I have, of course, only displayed links to these pages to qualified users.

Any ideas?
 
Can't answer your question directly as I do not know. However, I have a similar application and I have simply added code at the beginning of the page that checks for such a case as you have described and if the person does not have access rights, it displays an error message explaining that the user does not have access rights or redirects them back to the default page of the application - otherwise, it will show the page as normal. The code outline you have above should be sufficient for your purposes (just put your error message in for the the HTTP error you would otherwise propose to raise). Hope this helps.

------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
yes there is i cant remember it tho, one of them things i learned but wasn't important enough to remember....


think it has something to do with servervariables .. i'll look into it more

but here's a little function i nabbed that will check a requested page, not the current reques tho :

Function GetURLResponse(strURL)
Dim objXMLHTTP, strReturn
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.Open "GET", strURL, False
objXMLHTTP.Send
responseReturn = objXMLHTTP.status
Set objXMLHTTP = Nothing
GetURLResponse = responseReturn
End Function

[thumbsup2]DreX
aKa - Robert
 
that winhttp component can be used server side to establish the status of a request same with the xmlhttp function call.

[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top