redirect back to referrer

H

Hellp

Any help appreciated.

Have users on the local area net work post to an Aspx page. The page
process some post data.

I would like to return the user's browser back to the sumbit page. I
have tried

hplReturn.NavigateUrl = Request.UrlReferrer.ToString

but get the following error:

"Object reference not set to an instance of an object"

Any help appreciated

DJ
 
B

Bruno Piovan

the first page opened doesnt have a referrer, so check if
request.UrlReferrer is nothing first. like:

if not request.UrlReferrer is nothing then
response.redirect (request.UrlReferrer.tostring)
end if

Bruno
 
H

Hermit Dave

what if they directly typed the url or used the link from favourites...
there wont be no referrer.
so check for
first things first
if(!Page.IsPostback)
{
ViewState["URLReferrer"] = Request.UrlReferrer;
}

when you want to direct
if(ViewState["URLReferrer"] != null)
{
Response.Redirect(Convert.ToString(ViewState["URLReferrer"]))'
}
else
{
Response.Redirect("~");
// ~ redirect to current application's default page
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top