更改ASP.NET MVC 3的文件夹结构 [英] Changing ASP.NET MVC 3 folder structure
问题描述
我感兴趣的是改变结构的文件夹。我看了很多文章,但我还没有找到解决方法。
I am interested in changing the structure folder. I have read many articles, but I have not found the solution.
我想这样做的文件和文件夹分配专题文件夹。我从RazorViewEngine创建一个基类BaseViewEngine
I want to do so to distribute the files and folders on thematic folders. I have created a base class BaseViewEngine from RazorViewEngine
public class BaseViewEngine : RazorViewEngine
{
public BaseViewEngine()
{
MasterLocationFormats = new[]
{
"~/Themes/My/master.cshtml"
};
ViewLocationFormats = new[]
{
"~/Modules/{1}/{0}.cshtml"
};
PartialViewLocationFormats = new[]
{
"~/Blocks/{0}.cshtml"
};
}
}
但它不工作。
Control是原始的。仅用于测试
Control is primitive. Only for test
public class HomeController : Controller
{
public ActionResult Index()
{
var test = new Test { Text = "Hello" };
return View(test);
}
}
和查看
@model DemoModules.Test
<h2>Index</h2>
但是当我运行项目。我得到错误
But when I run project. I Get error
CS0103:在模式的名称呢
在当前上下文中不存在
CS0103: The name of the 'model' does not exist in the current context
关于结构的文件夹,看到的题材来源
About structure folder, see the source of subject matter
推荐答案
看看在默认浏览文件夹中的web.config文件。那里面有一些东西对剃刀意见工作所需要 - 特别是基类的观点和将要用于编译视图的命名空间。
Take a look at the web.config file in the default Views folder. There's some stuff in there that is required for Razor views to work - particularly the base class for views and the namespaces that will be used to compile the view.
这篇关于更改ASP.NET MVC 3的文件夹结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!