从MVC网站之外的位置加载视图 [英] Load views from location outside the mvc website
问题描述
我正在尝试从应用程序位置之外的文件夹中加载MVC视图.
我的应用程序位于C:\dev\myproject\
中,而我要加载的视图文件位于D:\viewsfolder\something
中,可以这样做吗?
我尝试将绝对路径传递给return View()
方法,但这没有用.
标准ASP.NET MVC不支持此功能.您可以看一下 RazorEngine plugin
,它允许您从字符串中渲染Razor视图./p>
您还没有真正解释为什么需要这样做.也许有解决您特定问题的更好方法.
I'm trying to load an MVC view form a folder outside the location of the app.
My app is in C:\dev\myproject\
and the view file i'm trying to load is located in D:\viewsfolder\something
is it possible to do that?
I tried passing an absolute path to the return View()
method but that didn't work.
This is not supported by standard ASP.NET MVC. You may take a look at the RazorEngine plugin
which allows you to render a Razor view from a string.
You haven't really explained why you need to do that by the way. Maybe there's a better approach to your particular problem.
这篇关于从MVC网站之外的位置加载视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!