1

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?

Andras Zoltan
  • 41,961
  • 13
  • 104
  • 160

1 Answers1

0

probably you can do very little about this, see questions and answers linked below, my main point would be that if you do not have the usual web.config in the web application folder from where do you get the connection string required to access the database? A single and default entry point for the settings is anyway required or unless you customize everything like using other text files or environment variables, you would not know how to reach and connect to the db.

see here amyway:

Using ConfigurationManager to load config from an arbitrary location

Loading a different web.config file at runtime fo ASP.NET

Community
  • 1
  • 1
Davide Piras
  • 43,984
  • 10
  • 98
  • 147
  • Well, the conection string isn't necessarily an issue as I'm using a proprietary IOC container that sits outside of web.config. I still want the root web.config - just a way to redefine as normal for a virtual path that's actually mapped to a DB. These links may well prove useful, though, thanks. – Andras Zoltan Oct 26 '11 at 10:08