Tuesday, January 18, 2011

Stopping IIS 6 Caching

One issue that I faced when deploying an ASP.NET 3.5 web application on IIS 6 (Windows Server 2003), was that web-pages always showed old data.

For example a GridView didn't show inserted or updated data unless we refresh the page (F5). Or if we restart IIS (iisreset).

After some googling it was apparent that this is an IIS6 issue.
And every try to solve it by setting caching and expiration settings in IIS 6 failed.

The only solution we found working is to hardcode the following in Global.asax

protected void Application_EndRequest(Object sender, EventArgs e)
{
HttpContext.Current.Response.CacheControl = "no-cache";
}

WebForm_postbackOptions is undefined

Yesterday we were deploying an ASP.NET application on a Windows Server 2003 & IIS6.

And suddenly we stumbled acorss a script error on every page the error was:
"WebForm_postbackOptions is undefined" and it was complaining about Scriptresource.axd

It turned out to be the server clock (date in specific) was not correctly set.
It was set somewhere in the past. And so IIS felt something fishy was going on, as the assemblies required to be loaded have build dates in the future.

It took us quite some time to come to the core of this issue, having to go through many articles on the net, describing different causes and solutions to the same error.

We got the hint from Siderite blog. Thanks be to him :)