.NET Generic Handlers and a Pain in the Neck

2010/03/31 at 16:18 Leave a comment

I’m using Microsoft Virtual Earth to map locations for a project that I’m working on. This is all fine and good. I’m using a GeoRSS feed to populate points on my map with code like this:

image

The issue here, is that my ashx handler that was providing the GeoRSS feed was somehow being cached. So updates to data would NOT be reflected on the GeoRSS feed until I closed and opened the browser window. This was not good.

Enter Response Headers:

context.Response.Headers.Add("Pragma", "no-cache")
context.Response.Headers.Add("Cache-Control", "no-cache")

I’m saved right? Not a chance. Using the above syntax will result in an exception to the effect of “Requires IIS integrated pipeline mode” Turns out that this is an IIS 7.0 ONLY feature; this is not supported on IIS 6, what I’m using since there is no IIS 7.0 for Windows Server 2003.

A quick swap from

context.Response.Headers.Add("Pragma", "no-cache")
context.Response.Headers.Add("Cache-Control", "no-cache")

to:

context.Response.AddHeader("Pragma", "no-cache")
context.Response.AddHeader("Cache-Control", "no-cache")

and you’re all set.

I’m still kinda peeved that .Net does not account for the operating system (and thus IIS version) and adjust the call accordingly. I thought one of the reasons for .Net was to write ONE VERSION of your application and deploy to ANY operating system, and provided you did not use any [DllImports] your application was supposed to work. Overall, still very happy with .Net but kinda peeved about this one.

Advertisements

Entry filed under: Uncategorized.

Understanding how I learned, to keep learning better Developing for Windows Phone 7, thoughts after a few months on task

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


My Most Recent Updates

Error: Twitter did not respond. Please wait a few minutes and refresh this page.


%d bloggers like this: