views:

329

answers:

3

I've got a virtual path provider (VPP) that serves simple aspx pages. The problem lies when I introduce static references such as *.css, *.jpg files, etc ...

I noticed my VPP is capturing these requests. I don't want this to happen. I want the normal System.Web.StaticFileHandler to handler these requests.

I've added the following in my web config:

    <system.web>
 <httpHandlers>
  <add verb="GET,HEAD" path="*.css" type="System.Web.StaticFileHandler" />
  <add verb="GET,HEAD" path="*.js" type="System.Web.StaticFileHandler" />
  <add verb="GET,HEAD" path="*.jpg" type="System.Web.StaticFileHandler" />
  <add verb="GET,HEAD" path="*.gif" type="System.Web.StaticFileHandler" />
 </httpHandlers>
</system.web>

But my VPP still handles these requests. Any ideas?

cheers in advance

A: 

I guess the VirtualPathProvider is invoked for every request. You'll have to override the FileExists method to tell the runtime whether the request is handled by the VirtualPathProvider or not.

M4N
Already doing that - slimmed down version: public override bool FileExists(string virtualPath) { if (virtualPath.EndsWith(".aspx")) return true; else return false; }
A: 

Actually, I'm having just the opposite problem. I want my VirtualPathProvider to server requests to image files but it doesn't work. Image files are ignored and IIS gives the typical "resource cannot be found" message. Otherwise, my VPP does work. Any ideas?

Johann
A: 

In response to Johann:

Add application extensions for the file types you need. You can copy the settings from the .aspx extension. You can find the settings in Home Directory > Configuration of the website properties in your IIS settings.

HTH.

Guido Smeets