Session variable launched by Chrome and FF

In my asp.net web application, on page load, I grab the current page URL and save it in a session variable to keep track of which page the user is on so that they can return to it if they are in the admin area, do some navigation around etc. Then they can press the return button and will be sent to the page on which they were, before entering the admin.

All this works in IE8; however, in FF and Chrome, when in admin, the backlink is redirected to the 404 user page that I have for the web application.

For testing purposes, I added the code that I wrote below with my page load event:

Response.Write((string)Session["navurl"]);// displays "http://somedomain.com/customerror/default.aspx" Session["navurl"] = currentUrl;//ex. currentUrl = "http://somedomain.com/contact/" Response.Write((string)Session["navurl"]);//ex. currentUrl = "http://somedomain.com/contact/" 

Again this works without problems in IE, but in FF and Chrome on the page load, the session variable displays a 404 page link, and after setting it, the correct link is displayed. I used a violinist to see what happens, and Chrome throws 404 in the GET header for the favicon.ico file, which I do not use in this web application.

I added the faviocon file and the link in the site.master file, and Chrome and FF now work fine; I'm still not sure why this is happening. Does anyone have any idea why and how my Session variable is being overwritten by Chrome or FF?

As a side note, I stepped through the debugging process, and currentUrl is the correct URL.

+8
google-chrome session-variables
source share
2 answers

Well, if you use the .NET handler to serve all pages (i.e. all file extensions), then it makes sense that when your browser makes a request to favicon.ico (google to understand what it is), the server does not find and redirects it to 404. Which, in turn, changes the session variable as a "last served page": 404.

Now that you create an admin page and request a session for the "last page", what do you get? "404".

I would suggest checking the url to see if it links to a navigable page before storing it in a session

 if (IsAUserPage(currentUrl) Session["navurl"] = currentUrl; 
+1
source share

When you contact your administrator, do you keep your session? With Fiddler, did you see another request for your page? Find image tags using src = "" or iframes.

You must install Session var on each page, but you should never install it on the administration pages, only by creating a "Back" link. If you use Global.asax events, be careful to avoid changing var when serving admin pages.

0
source share

All Articles