views:

109

answers:

2

i am using this function to get link of page which refered current page (in Back Button) :- Shared Function RefererPage() As String Return HttpContext.Current.Request.ServerVariables("HTTP_REFERER") End Function

this function is working fine with mozilla firfox but not working with Internet Explorer (IE8) please tell me why is it not working and what to do to make it work.

A: 

IE8 will not send the HTTP 'Referer' header if the referring page uses JavaScript to perform the navigation. See this blog post for more info.

This is also discussed in this Stack Overflow question.

In general, the 'Referer' header is not guaranteed to work. It works most of the time, but it can be disabled or spoofed. So it's best to design your app to not rely on the referrer. For example, you could put something to identify where the user is coming from in the query string of the link URL.

If you do want to use the 'Referer' header, and you control the referring page, there is a JavaScript workaround described in the blog post I mentioned above.

If you don't control the referring page (e.g. visitors are coming directly from Google), you may be out of luck.

Richard Beier
give me example of code which i can use to refer back link (any function of asp.net or javascript) witch works fine with all browsers
Rajesh Rolen- DotNet Developer
I don't think there is any such code. As I said, this is an issue with IE8 that needs to be solved on the referring page (where the link is), not on the referred-to page. It's best to design your app not to rely on the referrer.
Richard Beier
then why its working with asp.net buttons
Rajesh Rolen- DotNet Developer
ASP.NET LinkButtons work by doing a postback. The IE8 limitation only applies when people use JavaScript to change the window location. Since a postback doesn't use JavaScript in this way, it's not affected.
Richard Beier
A: 

use server side button instead of html button then it will work fine with IE also.

Rajesh Rolen- DotNet Developer