该视图必须从WebViewPage派生 [英] The view must derive from WebViewPage

查看:485
本文介绍了该视图必须从WebViewPage派生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作的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,我发现在这里:
我可以指定自定义位置"搜索意见"在ASP.NET MVC?

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 继承(如解释此处的The认为必须从WebViewPage,或WebViewPage<获得;的TModel取代。),但是当我做这一点,我得到一个错误说我不能使用 @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派生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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