加载MVC网站之外的位置意见 [英] Load views from location outside the mvc webiste

查看:144
本文介绍了加载MVC网站之外的位置意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载一个MVC视图形成应用程序的位置之外的文件夹中。

I'm trying to load an MVC view form a folder outside the location of the app.

我的应用程序是 C:\\ dev的\\ MyProject的\\ ,我试图加载位于 D视图文件:\\ viewsfolder \\东西是有可能做到这一点?

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.

任何想法?

推荐答案

这不是由标准的ASP.NET MVC的支持。你可以看看在 RazorEngine插件 这可以渲染从一个字符串的Razor视图。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆