views:

54

answers:

1

Hi, I have implemented my own VirtualPathProvider for loading 'embedded' views.

This works very well when running from Visual Studio, but I get the 'The view not found' message when running on IIS6.

Is there anything missing in web.config, or could there be any other problem?

I have added some logging and it seems that even though I register the Custom VirtualPathProvider in Application_Start, the System.Web.Hosting.MapPathBasedVirtualPathProvider is still used.

A: 

Is yours not used at all? VirtualPathProviders operate in a stack so, in your VirtualPathProvider, you should notice that the base class member "Previous" is actually the instance of "MapPathBasedVirtualPathProvider".

If you:

  1. Attach your debugger to IIS

  2. Make a change in your web.config, then change it back, then save (to trigger an recycle) - while still attached!

  3. Place a breakpoint in your VPP in FileExists

  4. Hit a page

Does your VPP get hit? If so, it may be an issue that after the first request, MVCs ViewEngine caching is preventing your VPP from getting hit for additional requests...

JeffN825
I haven't tried this yet. But, I have created a custom View Engine, where I log its VPP (this.VirtualPathProvider) in the FindView() method. My custom VPP never appears in the logs, and I believe both cached and uncached views pass through that method.
Bertvan
If your VPP isn't even showing up in the ViewEngine, are you 100% sure the Application_Start method is getting called to register the VPP? Is the registration the very first line in Application_Start? If not, try placing it so. There are very limited number of places where a VPP registration can actually take effect.
JeffN825