So in my MVC 3 site I have a path ~/_Content/*
mapped both to an MVC route to serve jpgs, gifs from a database but also I have a custom VirtualPathProvider
that picks up these urls and traverses a database structure to pick up Razor (and ASPX if needed) pages.
I've got all that working nicely - after a day trying to figure out how to get SqlCacheDependency
to work with entity framework queries (an entirely other story) - I can now request Razor pages and they get compiled and executed; and they'll get rebuilt when the underlying file changes in the database.
The next step will be to be adding additional ViewLocationFormats
(et al) to my ViewEngines to support finding Views in the database.
But now I've got another issue: these pages need to inherit from WebViewPage
or WebViewPage<TModel>
in order to work with the site's normal Layout page.
While I can obviously use @inherits
I'd rather just have it 'work' - so, the logical thing to do is to embed a web.config in the content hierarchy which has something very similar to the one that's in the standard ~/Views
folder.
The thing is, on trying this, Asp.Net doesn't pay any attention to that - presumably because it's only looking for web.config files that are physically on the disk.
I can use a <location path="_content" ...
directive in the site's main web.config - but ideally I'd like to be able to have fine-grained control from the content database end as well.
How can I get Asp.Net to pick up and, ideally, auto-discover these content-managed web.configs?