asp.net-mvc-3 – 更改ASP.NET MVC 3文件夹结构

前端之家收集整理的这篇文章主要介绍了asp.net-mvc-3 – 更改ASP.NET MVC 3文件夹结构前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有兴趣更改结构文件夹.我读过很多文章,但我还没有找到解决方案.

我想这样做,以将文件文件夹分发到专题文件夹.我已经从RazorViewEngine创建了一个基类BaseViewEngine

  1. public class BaseViewEngine : RazorViewEngine
  2. {
  3. public BaseViewEngine()
  4. {
  5. MasterLocationFormats = new[]
  6. {
  7. "~/Themes/My/master.cshtml"
  8. };
  9.  
  10. ViewLocationFormats = new[]
  11. {
  12. "~/Modules/{1}/{0}.cshtml"
  13. };
  14.  
  15.  
  16. PartialViewLocationFormats = new[]
  17. {
  18. "~/Blocks/{0}.cshtml"
  19. };
  20. }
  21. }

但它不工作.

更新

控制是原始的只用于测试

  1. public class HomeController : Controller
  2. {
  3. public ActionResult Index()
  4. {
  5. var test = new Test { Text = "Hello" };
  6. return View(test);
  7. }
  8.  
  9. }

和视图

  1. @model DemoModules.Test
  2.  
  3.  
  4. <h2>Index</h2>

但是当我运行项目我得到错误

CS0103: The name of the ‘model’ does
not exist in the current context

关于结构文件夹,查看主题的来源

解决方法

看看默认的Views文件夹中的web.config文件. Razor视图工作需要一些东西,特别是视图的基类和用于编译视图的命名空间.

猜你在找的asp.Net相关文章