JSEDLAK » MVC

Posts Tagged ‘MVC’

Cache Problems with ASP.NET MVC Views?

If you have done any decent amount of work with the ASP.NET MVC platform, you have probably run into the following problem. You have a page where you want to update data on the server without a postback and so you whip out some fancy Javascript to send a request to the server. What happens is the response you get back is a success, and the data is updated, but subsequent requests don’t seem to be updated. This is most noticeable with partial views and content views called via the infamous “$.ajax” call. What you forgot was to make sure the browser isn’t caching the result:

?View Code CHSARP
1
HttpContext.Response.AddHeader("cache-control", "no-cache");

Note that if you have already hit the particular view and it is cached, you can generally clear the cache by navigating to the URI of the view manually and hitting refresh.

IIS For Dummies: Allowing Anonymous Access!

Pro-tip for today: When attempting to create a website (I am using ASP.NET MVC 1.0) with IIS7 that allows anonymous users under an Active Directory domain it is imperative that you remember to give anonymous users read rights to the web directory on the system’s physical file system. Otherwise you could end up with pages that do not load the CSS correctly.

Furthermore, if you are running into assembly load problems when running on Windows Server 2008 R2 remember that everything is running in X64 and that you need to enable 32-bit compatibility in your Application Pools. To do this select the App Pool and click “Advanced Settings” and set “Enable 32-Bit Applications” to true.