Last post Jul 31, 2011 06:10 PM by MrDotNetDude
Jun 08, 2011 03:41 PM|Rinaldo|LINK
I have an ASP.NET 4.0 application that works well under the development machine, using IE8. I can debug it with success and my session variables are correct through the application. But when this application is published to the production server, the application
runs well on Firefox but raise errors on IE. I found that the problem is that my session variables are lost when the application is called by IE.
This was an ASP.NET 3.5 application that was migrated to 4.0. The older version works ok on every browser.
The application uses Forms Authentication.
Can anyone give me a hint on what the problem could be?
Jun 09, 2011 01:38 AM|hemant.yadav|LINK
I think there has some exception generated when you run your application in IE. Log the exception and check it that. Check your browser cookie is enable or not if not then enable it
Log the exception and checked it and you will get the solution
Jun 09, 2011 09:10 AM|Rinaldo|LINK
The exception is an "Object reference not found" exception due to the fact that the session variable is lost. We have discovered that the site runs ok on FireFox and IE9 under prodution. It raises the error on IE6, IE7 and IE8.
The production server has Windows 2003/IIS6 and cookies are enabled on all browsers. Could it be something related to an ASP.NET 4.0 and IIS6 configuration?
Jun 09, 2011 09:34 AM|GPankaj|LINK
Check the configuration setting for ASP.NET 4.0 and IIS 6
Hope this article gives you an idea to resolve the issue
Jun 09, 2011 02:19 PM|Rinaldo|LINK
Thanks GPankaj, but none of the links helped.
Now I am trying to host the site on IIS7 but the same problem occurs. Session is loaded on the first page but when I try to acces it on the second page, there is no more session available!
Jun 10, 2011 12:43 AM|hemant.yadav|LINK
Does it happening in IE only or in other browser also you getting same problem?? That seem to be some genium problem in your code.
This is not related to IIS 6 and IE
Can you post your code??
Jun 10, 2011 10:42 AM|Rinaldo|LINK
It happens on IE6, IE7 and IE8 but it works ok on IE9 and FireFox.
These are the relevant pieces of code on the Login screen:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session.Item("SessionUser") Is Nothing Then
Session.Add("SessionUser", New UserStore)
Private Sub cmdEntrar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEntrar.Click
Dim obj As UserStore = DirectCast(Session.Item("SessionUser"), UserStore)
.Login = txtLogin.Text.Trim
.Active = True
Protected Sub CreateTicket(ByVal userName As String, ByVal mainRole As String)
Dim ckData As HttpCookie = Nothing
Dim fatCurrent As FormsAuthenticationTicket = Nothing
Dim fatOld As FormsAuthenticationTicket = Nothing
ckData = FormsAuthentication.GetAuthCookie(userName, False)
fatOld = FormsAuthentication.Decrypt(ckData.Value)
fatCurrent = New FormsAuthenticationTicket(fatOld.Version, fatOld.Name, fatOld.IssueDate, fatOld.Expiration, False, mainRole, FormsAuthentication.FormsCookiePath)
ckData.Value = FormsAuthentication.Encrypt(fatCurrent)
Catch ex As Exception
After the login, the next screen simply try to read the session variable on its Page_Load event. I see that in fact the session variable is there but empty, which leads me to believe that something is erasing the values on the session variable during the
Jun 12, 2011 12:31 AM|Mamba Dai - MSFT|LINK
There are several reasons cause the losing Session variables . This links below about Losing Session variables you may have a check:
Jun 12, 2011 12:07 PM|Rinaldo|LINK
I found the problem and it was none of the typical issues.
The problem was related to the defaultDocument configuration element and an Image control without a Url set. The default document was being executed as the Url for the Image and because of this, redefining the session variable. Weird, but that was it. As
soon as we set the Url for the Image control the problem was gone.
But I am still trying to understand exactly what is the purpose of this behavior.
Jun 13, 2011 03:31 AM|Mamba Dai - MSFT|LINK
Jul 01, 2011 06:01 AM|Novox|LINK
Thanks for your sharing!! This solved my problem :)
Jul 31, 2011 06:10 PM|MrDotNetDude|LINK
I think I'm suffering from the same issue. If one launches the debugger with F5 from within a page's code-behind... does that page become the default document for that debug session?