HttpModule RewritePath ASP.NET Virtual Directory Cassette Not Updated

I have an ASP.NET IHttpModule implementation designed to rewrite file serving paths. The module processes only one event PostAuthenticateRequestas follows:

void context_PostAuthenticateRequest(object sender, EventArgs e)
{
    if (HttpContext.Current.Request.Path.ToLower().Contains("foobar"))
    {
        HttpContext.Current.RewritePath("virtdir/image.png");
    }
}

The virtdir path is a child of the application virtual directory. The application itself works in a typical place: C: \ inetpub \ wwwroot \ IisModuleCacheTest \ The virtual directory "virtdir" maps to C: \ TestVirtDir \

The request http://myserver/iismodulecachetest/foobarwill, as expected, return image.png from the virtual directory. Equally, the request http://myserver/iismodulecachetest/virtdir/image.pngwill return the same image file.

Then I do the following:

  • Inquiry http://myserver/iismodulecachetest/foobar
  • Directly change C: \ testvirtdir \ image.png (change the color in the paint and save).
  • Repeat

- 1 20 , , .

( 10 ). URL 1 http://myserver/iismodulecachetest/virtdir/image.png, . , , URL- "foobar", URL- .

:

  • .
  • .
  • . , , , , Iis stil .
  • web.config . <caching enabled="false" enableKernelCache="false" />
  • , , , , , image.png .
  • , , , , . , , Ctrl + F5, .
  • . Win7 Pro 6.1.7601 SP1 + IIS 7.5.7600.16385 Server 2008 R2 6.1.7601 SP1 + IIS 7.5.7600.16385.

- :

  • .
  • URL- http://myserver/iismodulecachetest/foobar.png.
  • IIS , context_PostAuthenticateRequest , , .

Edit2 - IIS:

" " IIS (, - , . 17, , , .

, :

Good request

, , , :

Bad request

, , . , IIS , , !: (

:

Good request 2

() :

Bad request 2

, , -, , FileDirmoned="true".

+5
2

- .

void context_PostAuthenticateRequest(object sender, EventArgs e)
{
    if (HttpContext.Current.Request.Path.ToLower().Contains("foobar"))
    {
        Random rnd = new Random();
        int randomNumber = rnd.Next(int.MinValue, int.MaxValue);
        HttpContext.Current.RewritePath("virtdir/image.png?"+randomNumber);
    }
}
+1

, RewritePath . , Server.TransferRequest, .

HttpContext.Current.Server.TransferRequest(newUrl);

IHttpModule, , .

0

All Articles