views:

270

answers:

1

Hello,
I am working on an Filter Attribute for ASP.Net MVC that will return a 304 response when the content has not been modified. It would be handy to be able to read the Last-Modified header value set in the Controller in order to accomplish this... there just seems to be one problem. I can't seem to find a way to read the headers when executing code like the following on Cassini [Visual Studio 2008 Dev Web Server]...

Response.AddHeader("Last-Modified", lastModified);
string getLastModified = Response.Headers.Get("Last-Modified");

I've also tried the following:

Response.AddHeader("Last-Modified", lastModified);
string getLastModified = Response.Headers["Last-Modified"];

Both return a PlatformNotSupportedException and indicate that they require "This operation requires IIS integrated pipeline mode."

Here are some details on the environment:

  • Framework Version: .Net 3.5 - SP1
  • IDE: Visual Studio 2008
  • Web Server: Cassini [Dev] and IIS6 [Production]

I'm probably missing a simple way to get this to work...
Thanks in advance,
Joe

A: 

Response.Headers isn't supported with Cassini or IIS 6. This is true for several other recent features, too, such as Server Variables.

Solution:

  1. Do your development with a local version of IIS 7 by configuring a web site in IIS to point to your dev files, and setting the start URL for your project accordingly. You can use ports other than 80 if you need to, for multiple projects.

  2. Switch your production site to use IIS 7 (probably with Windows Server 2008). There are a bunch of other good reasons to upgrade, too, such as improved performance.

If an upgrade isn't possible, the only alternative I can think of is to write an ISAPI filter to make the header changes (in C++).

RickNZ
Unfortunately, upgrading the server is not going to be an option at this time. But thanks for the response!
joe.liedtke
In that case, the only alternative that comes to mind is to write an ISAPI filter (in C++).
RickNZ