问题描述
我有一个工作的MVC应用程序时,我决定,是时候让一些维护。
我的观点是所有共享目录下,我决定将其移动到不同的目录。
I had a working MVC application when I decided that it was time for some maintenance.My views were all under SHARED directory and I decided to move them into separate directories.
我实现了一个CustomViewEngine,我发现在这里:
的
I implemented a CustomViewEngine that I found here:Can I specify a custom location to "search for views" in ASP.NET MVC?
查看结构lookes像这样
View structure lookes something like this
Views
AppViews
OtherAppViews
...
Shared
...
这是我得到一个错误:
在'〜/视图查看/浏览的应用数量/ SomeView.cshtml必须自ViewPage派生,
的ViewPage<的TModel>中ViewUserControl,或ViewUserControl<的TModel方式>
我试图从 @inherits System.Web.Mvc.WebViewPage
继承(如解释此处的),但是当我做这一点,我得到一个错误说我不能使用 @inherits
和 @model
在同一时间。
I tried to inherit from @inherits System.Web.Mvc.WebViewPage
(as explained here: The view must derive from WebViewPage, or WebViewPage<TModel>.) , but when I do this I get an error saying that I can't use @inherits
and @model
at the same time.
感谢您
推荐答案
您CustomEngine应该从 RazorViewEngine 而不是 WebFormViewEngine
,因为你使用.cshtml文件(剃刀引擎)。
Your CustomEngine should derive from RazorViewEngine
instead of WebFormViewEngine
since you use .cshtml files (Razor engine).
文件:
- 的
- 的
- RazorViewEngine
- WebFormViewEngine
这篇关于该视图必须从WebViewPage派生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!