views:

256

answers:

1

Hi, currently I have a custom VirtualPathProvider in a Asp.net MVC web application.

This VirtualPathProvider checks the Area from the route "/{Area}/{Controller}/..." and uses the NameSpace.{Area}.Main.dll module to return the views that are contained in that assembly as Embedded Resources.

This works great and I don't have to deploy any ascx, js, css files.

Now my problem is this:

I would like to precompile the aspx and ascx files in the assembly and instead of having the views as embedded resources I would have the view class with all the Response.Write and dings and dongs.

I can precompile the views using the aspnet_compiler but I keep getting an error when ever the ViewEngine tries to find the view and fails.

My main goal is to have a way for the first time usage of a certain view/usercontrol would be faster and don't wait for the compilation to happen.

This is a requirement since the application could be grouped into plugins and this plugins be deployed into the Bin directory.

Any thoughts?

With best regards Carlos Sobrinho

+1  A: 

This VirtualPathProvider In Precompiled Web Sites blog post by Coskun SUNALI describes a solution using reflection. Please note that he makes it very clear that this is not an officially supported solution from Microsoft but judging by the comments on his blog post it seems to be working well for some people.

Martin Hollingsworth
Just noticed that there was a similar question http://stackoverflow.com/questions/12397/net-virtualpathproviders-and-pre-compilation that already referred to this solution
Martin Hollingsworth
Thank you for your reply. I'm currently testing a solution using the Warmup feature of the new IIS 7.5 and automatically preloading all the pages to force a compilation... But I'll try this soon.Much appreciated!
epilog