该视图必须从WebViewPage或WebViewPage< TModel>派生.

编程入门 行业动态 更新时间:2024-10-27 06:31:03
本文介绍了该视图必须从WebViewPage或WebViewPage< TModel>派生.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在关注 Justin Slattery的插件架构教程并尝试使其适应Razor,而不是WebForm视图.

I'm following Justin Slattery's Plugin Architecture tutorial and trying to adapt it for Razor, instead of WebForm Views.

其他一切(控制器,插件程序集加载等)似乎都还可以.但是,我无法使嵌入式Razor视图正常工作.当我尝试浏览到"HelloWorld/Index"时,出现以下错误:

Everything else (controllers, plugin assembly loading, etc) seems to be okay. However, I'm not able to get embedded Razor views to work properly. When I try to browse to the "HelloWorld/Index", I get the following error:

The view at '~/Plugins/MyProjectPlugin.dll/MyProjectPlugin.Views.HelloWorld.Index.cshtml' must derive from WebViewPage or WebViewPage<TModel>.

System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +262

如果需要,我可以包括完整的堆栈跟踪.

I can include the complete stack trace, if needed.

有人可以告诉我我可能做错了什么吗?

Can anyone advise as to what I might be doing wrong?

推荐答案

您可以签出下面的博客文章,它更适合Razor.

You may checkout the following blog post which is more adapted to Razor.

但是要回答您的问题,由于您现在是从非标准位置提供视图,因此不再有适用的~/Views/web.config文件,该文件允许您指定剃刀视图的基本类型.因此,您可能需要在每个剃刀视图的顶部添加以下内容:

But to answer your question, since you are now serving your views from a non standard location there is no longer the ~/Views/web.config file that applies and allows you to specify the base type for your razor views. So you might need to add the following on the top of each razor view:

@inherits System.Web.Mvc.WebViewPage @model ...

更多推荐

该视图必须从WebViewPage或WebViewPage&lt; TModel&gt;派生.

本文发布于:2023-11-10 00:32:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   WebViewPage   amp   gt   TModel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!