Tuesday, 15 May 2012

c# - How to load some views from database, and others from files in MVC4 -



c# - How to load some views from database, and others from files in MVC4 -

im having web application loads _layout , normal page views file, , seek load partial views database using virtualpathprovider , overriden virtualfile:

public class ravendbpathprovider : virtualpathprovider { public override bool fileexists(string virtualpath) { if (!virtualpath.startswith("textcontents/")) homecoming false; using (var session = objectfactory.getinstance<idocumentsession>()) { homecoming session.query<textcontent>().any(w => w.id == virtualpath); } } public override virtualfile getfile(string virtualpath) { if (!virtualpath.startswith("textcontents/")) homecoming base.getfile(virtualpath); homecoming new ravendbvirtualfile(virtualpath); } }

i register provider in global.asax:

hostingenvironment.registervirtualpathprovider(new ravendbpathprovider());

however, when register ravendbpathprovider seems gets used view lookups.

is possible register multiple virtualpathproviders if view cant found on disk search go on in database?

if not, has done similar success?

c# asp.net-mvc-4 virtualpathprovider

No comments:

Post a Comment