I'm playing around a little with dividing up a MVC-site into several assemblies (ran into some issues earlier).
Now I have almost everything working, got the main MVC project that loads in any external assemblies it can find. The external assemblies are basically external areas. When I had it copy the Views and web.config to the main-sites Areas-folder everything worked just fine. Now, that folder will most likely start to get a little bloated after a while, so I thought I'd try to add in the Views as resources in the area-assembly instead, see how that worked.
Created my own VirtualPathProvider
and my own VirtualFile
, registered them with the HostingEnvironment
thinking all was well. Turns out it only uses the VirtualPathProvider
added to the HostingEnvironment
at the first load, not by the following View-loads by the ViewEngine
.. Ok fine, found a few examples of how you could get around this by implementing your own ViewEngine
to use your own VPP. But yeah, this doesn't seem to be a workable solution for MVC 3..
As it turns out, neither RazorViewEngine
nor WebFormViewEngine
implement two of the "key-functions" it seems, FileExists
and IsValidPath
. These are inherited from BuildManagerViewEngine
, and you know what? These methods are marked as sealed
..
Anyone who has tried this with MVC 3 and perhaps could nudge me in the right direction? I've been staring at the MVC 3 source now for quite a w开发者_StackOverflow社区hile but I just can't see any way of doing this..
Now I feel a little stupid, it seems I loaded the VPP too late.. Had it in Application_Start
, but when I moved it to my PreApplicationStartMethod
instead, it was used by the ViewEngine
. (So no implementation of ViewEngine
seems to be needed, wey!)
Problem now is that when I try to get to a View that's stored as a resource, I get to download it instead of having it rendered.. But that's something different from this so!
精彩评论