views:

266

answers:

1

I have an ASHX handler or an ASPX page (the problem happens in both cases). The web client sends a request containing If-None-Match and/or If-Modified-Since headers but context.Request.Headers.Get("If-None-Match") or context.Request.Headers.Get("If-Modified-Since") is null in the handler.

The same script works in my local development machine but it doesn't work in the online machine (both are running IIS7 on Win 2008, .NET 3.5)

A: 

Hello, You may use 3rd-party module to create duplicates of those headers before apsx page is executed. For example with Helicon Ape (http://www.helicontech.com/ape) these rules may do the trick:

SetEnvIf If-None-Match (.*) e-if-none-match=$1
SetEnvIf If-Modified-Since (.*) e-if-modified-since=$1

RequestHeader set My-If-None-Match %{e-if-none-match}e
RequestHeader set My-If-Modified-Since %{e-if-modified-since}e

Basically they get the headers and set the new ones with My- prefix. This will work only if IIS doesn’t remove headers before Ape.

Slava
Thanks, but any idea why does IIS remove those headers?
I noticed that the header is available when I access the handler from the local computer, but IIS removes it when I access the handler from a remote computer.Also I tried to create a IHttpModule, but it doesn't help because the header has been already removed before HttpApplication.BeginRequest is called.
I suggest you to ask on iis.net forums. I honestly don’t know why IIS removes those headers. It’s quite possible though, because I know for sure that IIS'es low-level driver adds Content-Length header after all the modules. The same thing with Server header.
Slava