ScottGu mentioned that we should be able to load a Razor view from a database (check the comments section), so does anybody have an example on how to do that?
Thanks.
ScottGu mentioned that we should be able to load a Razor view from a database (check the comments section), so does anybody have an example on how to do that?
Thanks.
You might want to check Pulling a View from a database rather than a file or Using VirtualPathProvider to load ASP.NET MVC views from DLLs
Taking the code from my previous question on the subject.
In your
FileExists()
method on the other page you replace the test code I have there with some db code that actually checks to see if the virtualPath has an entry in your database. Your database would look something like:...and your call would then be something like
And now we modify the DbVirtualFile
The virtualPath doesn't have to correspond to a real filesystem if you don't want it to. You can override the functionality by implementing these two classes.
You can then register your new VirtualPathProvider in the global.asax like so
I hope this better answers your question.