Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

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 :)

Sunday, November 7, 2010

Parser Error

I was deploying an ASP.NET application on IIS 5.1 the other day, when I was hit by the following error when trying to access some of the aspx pages from the browser.

/*********************************************************************************/

Server Error in '/' Application.
--------------------------------------------------------------------------------
Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls.


Source Error:
Line x: [/asp:content]

Line x+1:

/*********************************************************************************/

All pages were content pages of some master page. And nothing was written after the closing content tag.

At first I thought this was some kind of .NET vs IIS version mismatch or that I needed to change some IIS settings, since this was running fine on different IIS versions.

But to my surprise, some pages were displayed fine.

After banging my head few times, I found out the cause. The pages that were complaining had some spaces and empty lines after the closing content tag. This should mean nothing in html, but I guess IIS 5.1 didn't like these.

Clearing everything so that the closing content tag is practically the last thing written in a page, did the trick.

Hope this becomes helpful to anyone facing the same issue.