p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Basics (http://p2p.wrox.com/forumdisplay.php?f=60)
-   -   object required Request (http://p2p.wrox.com/showthread.php?t=52239)

RoniR January 4th, 2007 07:33 AM

object required Request
 
hi guys i am having this error generated from this code
<html>
<head>
<SCRIPT LANGUAGE="VBScript">

dim ReturnUrl
ReturnUrl=request.ServerVariables("HTTP_REFERER")
</SCRIPT>

</head>
<body>
<p align=center>
<b>"An error has occured! Sorry for the inconvenience ..." </b>
    <br><br>
    <a href="<%=ReturnUrl%>"> Return To Page </a>
</p>
</body>
</html>

Object required:Request
Now i know that i used the request object in a client-side script. The client does not have any notion of the ASP environment so
what i am truying to do cannot be done in this manner. All i want is to create an error page for my asp.net website..i mean when an error occurs it goes to this page error.html,shows the message An error has occured! Sorry for the inconvenience ..." and then offer the user a link to go back to were he was which can be handeled by request.servervariables("HTTP_REFERER").I got stuck on my method and cant find any other way.Ur Help is appreciated.10x


vinod_yadav1919 January 4th, 2007 09:05 AM

Hi RoniR!!
Two ways to do samething
**********test1.asp**********
<html>
<head>
</head>
<body>
<SCRIPT LANGUAGE="VBScript" runat="server">

dim ReturnUrl
ReturnUrl=request.ServerVariables("HTTP_REFERER")

response.write("<p align=center>")
response.write("<b>""An error has occured! Sorry for the inconvenience ..."" </b><br><br>")
response.write("<a href='"&ReturnUrl&"'> Return To Page </a>")
response.write("</p>")
</SCRIPT>
</body>
</html>
***************test2.asp*************
<html>
<head>
<%
  dim ReturnUrl

ReturnUrl=request.ServerVariables("HTTP_REFERER")
%>
</head>

<body>
<p align=center>
<b>"An error has occured! Sorry for the inconvenience ..." </b>
    <br><br>
    <a href="<%=ReturnUrl%>"> Return To Page </a>
</p>
</body>
</html>
***************
Note:-
In first method you only need to specify runat=server so that ur script will run on the server,since on the client side (when u use <SCRIPT LANGUAGE="VBScript">) ,there is no request object ,that browser can understand.

hope this will help you




Cheers :)

vinod

RoniR January 5th, 2007 02:53 AM

hey thanks for the reply..Your first method didnt work i still got the same error. The second one worked fine .I just cant seem to be able to fill the variable ReturnUrl with the value of Request.ServerVariables("HTTP_REFERER") in the <a href="<%=ReturnUrl%>"> Return To Page </a>
ur help is appreciated.10x


vinod_yadav1919 January 8th, 2007 06:53 AM

Hii RoniR!!

Request.ServerVariables("HTTP_REFERER") is used with <a href> tag,and sometimes it gives null value to..

these links will help you
http://www.sitepoint.com/forums/showthread.php?t=310184
http://www.velocityreviews.com/forum...tpreferer.html

Cheers :)

vinod


All times are GMT -4. The time now is 04:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.