MVC6 Load razor views from database

心不动则不痛 提交于 2019-12-13 02:01:11

问题


We are working on ASP.NET MVC 6 project and it's necessary to load and then compile Razor views from an external source (Azure document database).

I see in other SO posts (<= MVC 5) it was possible to create and register a custom VirtualPathProvider which can take view content from DB or resource DLLs (for example).

What are the options for MVC 6 ?


回答1:


Technically not implemented yet. This is after all a rewrite and not just a set of new features.

I found a thread on GitHub which talk about a way to get what you need.

Basically, it's about providing your own implementation of IFileProvider.

I have virtually no experience in implementing this but I think that if you have time to spare, this is definitely the way to go.




回答2:


A bit late to the party, but if you are still looking at this I have just posted a sample project to GitHub showing how to store your .cshtml in Azure Blob storage using ASP.NET 5 / MVC 6.

@Maxime Rouiller - MVP is correct that you need to provide a custom IFileProvider. My sample is using rc1-final and working. Looking at the aspnet project though, this may change subtly later (will allow multiple providers to be registered)

A blog post write up on this should be coming in the next few days too.



来源:https://stackoverflow.com/questions/34281960/mvc6-load-razor-views-from-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!