I have an ASP.NET web application that, for whatever reason, when it is deployed on any IIS server, will behave like the pages are cached and it simply never posts back to the server.
For example, navigate to the login page, enter credentials, click the login button, and it’s back to the login page you go, with the form fields cleared. The information is not getting submitted back to the server. The postback is not executing. It seems the browser is simply restoring the original page from cache.
I found this article that says I need to put something in the ASP.NET session state in order for the session to remain valid.
When a user connects to an ASP.NET
application, a unique session ID will
be affiliated with the user. If
nothing is put in the session however,
no cookie will be sent to the browser.
This means that the user will get a
new session ID the next time a new url
is open or the page is refreshed. If
something is put on the session
(HttpContext.Current.Session[“Hello] =
“hello”) however, ASP.NET will issue a
cookie called ASP.NET_SessionId. This
cookie contains the user’s session ID
and the cookie will expire at the end
of the session (when you close your
browser).
I will try what that article recommends, as I had not been storing anything in the session.
I have also added expiration headers to the page:
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetNoStore()
and put some meta tags in the html:
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
Any other ideas as to what the cause of this behaviour may be?
The issue was related to IIS.
The
Directory Securityfor the web application was set to run only under anonymous access with a local user account and application pool specifically created for the application.Turns out,
Integrated Windows AuthenticationandEnable anonymous accessmust both be checked otherwise you’ll get this weird behaviour.FWIW, the ASP.NET web application is running in a FRAMESET/FRAME under a classic ASP site and the issue only occured when accessing the site from the local network. It worked fine externally. It also worked on the local network the first time it was accessed, then the session cookie would need to be cleared for it to work again.