- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将 MVC 添加到我现有的 webforms 项目中。除了 RenderAction 正在寻找 .aspx 文件之外,一切都很顺利
The view '_Mainmenu.cshtml' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Areas/NewPages/Views/Shared/_Mainmenu.cshtml.ascx
~/Areas/NewPages/Views/Shared/_Mainmenu.cshtml
最佳答案
The view '[viewname]' or its master was not found or no view engine support the searched Locations 表示您使用的是默认 View 引擎,它优先考虑 Web 表单 View 引擎(显示为 ~/Areas/NewPages/Views/Shared/_Mainmenu.cshtml.ascx
的路径表示 MVC View 引擎优先搜索 ASPX 和 ASCX 文件而不是 Razor cshtml 文件)。要更改 MVC 默认使用 Razor View 引擎的这种行为,请将这些行插入 Application_Start
方法在 Global.asax
:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
// ViewEngines.Engines.Add(new WebFormViewEngine()); => optional webforms engine registration
RazorViewEngine
和设置
AreaViewLocationFormats
在它的构造函数中是这样的:
public class CustomViewEngine : RazorViewEngine
{
public CustomViewEngine()
{
// Route parsing convention for view engines:
// {0} means action method name
// {1} means controller class name
// {2} means area name
AreaMasterLocationFormats = new[]
{
"~/Areas/{2}/Views/Shared/{0}.cshtml"
};
AreaViewLocationFormats = new[]
{
"~/Areas/{2}/Views/{1}/{0}.cshtml",
// other view search locations here
};
AreaPartialViewLocationFormats = AreaViewLocationFormats;
}
}
AreaViewLocationFormats
中定义的路由在 Controller 操作方法指定的区域内搜索所有 View 页面。 .
RazorViewEngine
相同的地方注册自定义 View 引擎类。 ,即在
Global.asax
:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
// clear all view engines repository first
ViewEngines.Engines.Clear();
// register Razor view engine only
ViewEngines.Engines.Add(new RazorViewEngine());
// register custom view engine class here
ViewEngines.Engines.Add(new CustomViewEngine());
// other initialization codes here
}
关于c# - 如何停止 MVC5 RenderAction 寻找 .aspx 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45097274/
我有一个 div 可以在我的页面上呈现图片库 @{ Html.RenderAction("UserGallery"); } 我有这个函数
为什么这段代码是正确的: @{ Html.RenderAction("PostImagesForPost", "BlogPost", new { id = Model.ID }); } 还
我的 Controller 中有 [ChildActionOnly],名为 _AllLinks 如果 _AllLinks.cshtml 在我的 Controller 目录中,我可以使用 RenderA
我的设置: 查看一条路线,如:/Pages/Details/2 页面详情 View 有呈现评论表单 评论表单发布到 Comments/CreatePageComment /Comments/Creat
我对 RenderAction() 函数的作用感到满意。但是,我想在部分渲染的操作中对数据的加载和存储进行ajaxify,以便一切都发生在一个页面中。 想象一下以下情况:我有一个文章详细信息 View
您好,我想知道 mvc C#s 渲染操作是否与直接在我的评论中调用部分一样有效,如果不是,那么效率有多低。 最佳答案 RenderAction 肯定会比 RenderPartial 慢。差异将取决于您
如何将一个类应用于以下对象,以便我可以对其应用特定的 css 样式? 其余部分由 anchor 标记组成,因此我可以轻松应用一个类,但是我应该将它粘贴到这个@Html.RenderAction 的什么
是否可以使用 HTMl.RenderAction 使用 ajax 提供参数? 我有一个这样的 Controller 操作 [ChildActionOnly] Public ActionResult E
当我的 View 显示 RenderAction 时,我在 Fiddler 中没有看到任何额外的请求调用。是不是因为它不是一个单独的 Web 请求,也就是说,它是在 Controller 呈现其 Vi
我有一个包含 (c => c.SidebarStats()); %> 的 ViewPage .在操作 SidebarStats 的 Controller 操作上,我有一个 OutputCache 操作
我正在扩展 htmlhelper。但我不能调用它的渲染 Action 。 using System.Text; using System.Web.Mvc; using System.Web.Mv
我正在创建一个使用区域的 ASP.NET MVC 2 (RTM) 项目。一个区域的Home Controller 的Index Action 需要使用RenderAction来生成页面的一个子区域。调
我有一个 PartialViewResult 操作,它呈现一个我从页面上的 $.ajax 调用调用的 PartialView。 该 PartialView 对于 VM 中的项目也有一个 foreach
我正在尝试在 Controller 操作中使用 Route 属性命名(例如:[Route(Name = "Abc123")]),并且同样能够通过 Html 调用它.RenderAction,但是貌似这
我正在阅读一本使用旧版本 Html.RenderAction 的 MVC 书籍.所以书上是这样的Html.RenderAction("Summary", "Cart");我不得不转换为 Html.Re
在我安装 ASP.NET MVC 1.0 RTM 之前,调用工作正常。 错误:CS0121:调用在以下方法或属性之间不明确 代码片段 操作方法 public ActionResult Product
我在 *.cshtml 文件中有一个 javascript $(function () { sliderDiv.slider({ range: true, min: minVal, max
我在将 CaSTLe Windsor Controller Factory 与新的 RenderAction 方法结合使用时遇到了问题。我收到以下错误消息: Controller “MyControl
我将 MVC 添加到我现有的 webforms 项目中。除了 RenderAction 正在寻找 .aspx 文件之外,一切都很顺利 The view '_Mainmenu.cshtml' or it
根据 Brad Wilson 的说法,RenderAction 比 RenderPartial 慢。 但是,有没有人得到任何显示性能差异的统计数据? 我正在开发一个应用程序,其中页面由“小部件”组成。
我是一名优秀的程序员,十分优秀!