有没有办法从响应头读取没有得到一PlatformNotSupportedException?没有办法、PlatformNotSupportedException

2023-09-07 10:19:51 作者:十四阙

我工作的一个过滤器属性的ASP.Net MVC将返回一个304响应时,该内容没有被修改。这将是很方便的能够读取器设置Last-Modified头部值,以便做到这一点?那里只是似乎是一个问题。我似乎无法找到一个方法来读取头执行像卡西尼[Visual Studio 2008中开发Web服务器] ...

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"];

这两个返回PlatformNotSupportedException,并表示他们需要此操作需要IIS综合管道模式。

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

下面是对环境的一些细节:

Here are some details on the environment:

Framework版本:NET 3.5的 - SP1 IDE:Visual Studio 2008中 Web服务器:卡西尼[开发]和IIS6 [生产]

我可能缺少一个简单的方法来得到这个工作... 在此先感谢, 乔

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

推荐答案

Response.Headers不支持卡西尼或IIS 6,这是真实的其他几个最近特点,也如服务器变量。

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

解决方法:

在IIS中配置一个网站指向你的dev的文件,并设置起始URL为你的项目做相应的开发与IIS 7的本地版本。如果需要,多个项目可以使用端口80以外。

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.

切换生产站点使用IIS 7(可能与Windows Server 2008)。还有很多其他的好理由升级,也如改进的性能。

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.

如果升级是不可能的,唯一的选择我能想到的是写一个ISAPI筛选器,使头部变化(C ++)。

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++).