• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1012
  • Last Modified:

Windows 2008 Server with IIS 7. Uses old (cahced?) pages.

Using ASP .Net 4.0 and IIS 7...

We have noticed that after putting new pages on our Windows 2008 Server running IIS 7, that the web server still uses the old page. For instance, we have code behind written in C# that appends an additional URL parameter when a button is clicked. Even though we have copied this new "aspx.cs" page to the server it is still using the old one from it's cache.

I have tried the following:

"touching" (saving) the "web.config" file
Recycling the App Pool
Renaming the "cs" file, hit the page, then rename it back.

Any other ideas on how to force IIS to reload/recompile?

  • 3
  • 3
1 Solution
As long as you have not precompiled your ASP.NET application using Visual Studio before deploying it then IIS should be recompiling your website every time a change to the source files is made.

Compiling on First Request

By default, ASP.NET Web pages and code files are compiled dynamically when users first request a resource, such as an ASP.NET page (.aspx file), from a Web site. After pages and code files have been compiled the first time, the compiled resources are cached, so that subsequent requests to the same page are extremely efficient.

Recompiling on Change

Any changes to a dynamically compiled file will automatically invalidate the file's cached compiled assembly and trigger recompilation of all affected resources. The next time a request to the code is made, ASP.NET recognizes that the code has changed and recompiles the affected resources of the Web application.


Understanding ASP.NET Dynamic Compilation

If you are not seeing any changes in your ASP.NET website when you are making changes it might be that the pages are being cached in your browser. Try using SHIFT + F5 to force the browser to reload the ASP.NET page direct from the web server.
Sorry its CTRL + F5 to force a refresh

dbaGrantAuthor Commented:
Hmm. After a day it is still using the old "aspx.cs" file. We are not "deploying" the changes, we are simply doing a filesystem copy of the file (the new aspx.cs) file.

This is very strang. I know there are no compile errors, we have compiled it locally. Besides, it is a simple append to a redirected URL (something like "&ID=123") that is triggered by a button handler event.
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

dbaGrantAuthor Commented:
I forgot to mention that we dont precompile.
Is it possible that someone has setup Output Caching on your server?

Internet Information Services 7 (IIS 7) includes an output cache feature that can cache dynamic PHP content (or output from your Microsoft® ASP.NET or classic ASP, or other dynamic pages) in memory. This can yield enormous performance improvements, since the script used to generate the dynamic output does not need to run for each request.

IIS supports two ways to invalidate dynamic content:

Use a simple timeout period - the configuration property is CacheForTimePeriod.

Detect a change to the underlying resource - the configuration property is CacheUntilChange. Use this type of invalidation scheme only when you want the cache flushed when the underlying resource changes.


Configure IIS 7 Output Caching


It might be that someone has setup output caching and specified a time period, and your page has been cached. So you are not getting the new version when you make a change.

The cache is fairly easy to configure using the user interface feature in the new IIS administration tool.

1. From the Start menu, click Administrative Tools, and then click Internet Information Services (IIS) Manager.

2. In the tree view on the left side, find your application/website.

3.Select the Output Caching menu item.

Check to see if there are any output caching rules already setup.

If you want to force IIS 7 not to cache aspx pages then you can add a rule for aspx pages.

4. In the right column, click Add in the Action menu. You can add your output caching rule here.

5. In the File name extension field, for example, type .aspx, and then select User-mode caching.

6. The chose one of the radio buttons i.e. using file changes, at time intervals, or prevent all caching.

If you want to test that caching is your problem then choose prevent all caching and see if your page changes as expected.
dbaGrantAuthor Commented:
I will try this. Something else we noticed, is if we use the Visual Studio Solution that is stored in the directory of the web appliation, then the changes take effect immediately. (But, if we say make the changes on a dev server, then copy just the new aspx files, they are cached).

The Output Caching IS setup, but there are no rules. So, does that mean it is caching everything (or nothing)?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now