视图或主人未找到或没有视图引擎支持搜索到的位置 [英] The view or its master was not found or no view engine supports the searched locations
问题描述
像错误:视图'登录登录注册或它的主人没有被发现或没有视图引擎支持搜索位置。在以下地点进行了全面搜查:
〜/查看/我的帐户/ LoginRegister.aspx
〜/查看/我的帐户/ LoginRegister.ascx
〜/查看/共享/ LoginRegister.aspx
〜/查看/共享/ LoginRegister.ascx
〜/查看/我的帐户/ LoginRegister.cshtml
〜/查看/我的帐户/ LoginRegister.vbhtml
〜/查看/共享/ LoginRegister.cshtml
〜/查看/共享/ LoginRegister.vbhtml
块引用>其实我的页面视图页面
〜/查看/家庭/ LoginRegister.cshtml
所以我做什么和我的
RouteConfig
是公共类RouteConfig
{ 公共静态无效的RegisterRoutes(RouteCollection路线)
{
routes.IgnoreRoute({}资源个.axd / {*} PATHINFO); routes.MapRoute(
名称:默认,
网址:{控制器} / {行动} / {ID}
默认:新{控制器=我的帐户,行动=登录登录注册,ID = UrlParameter.Optional}
);
}
}
解决方案此外,仔细如果您的机型为String 。因为,查看的第二个参数 - 字符串(主机名),但你可能需要调用与对象参数(模型)第一个构造函数
。不正确:
受保护的ActionResult ShowMessageResult(string信息)
{
返回视图(信息,味精);
}正确:
受保护的ActionResult ShowMessageResult(string信息)
{
返回视图(信息,(对象)MSG);
}Error like:The view 'LoginRegister' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/MyAccount/LoginRegister.aspx
~/Views/MyAccount/LoginRegister.ascx
~/Views/Shared/LoginRegister.aspx
~/Views/Shared/LoginRegister.ascx
~/Views/MyAccount/LoginRegister.cshtml
~/Views/MyAccount/LoginRegister.vbhtml
~/Views/Shared/LoginRegister.cshtml
~/Views/Shared/LoginRegister.vbhtml
Actually my page view page is
~/Views/home/LoginRegister.cshtml
so what i doand my
RouteConfig
ispublic class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "MyAccount", action = "LoginRegister", id = UrlParameter.Optional } ); } }
解决方案Also, be carefully if your model type is String. Because, second parameter of View - string (master name), but you maybe need to call first constructor with object param (model).
Not correct :
protected ActionResult ShowMessageResult(string msg) { return View("Message",msg); }
Correct :
protected ActionResult ShowMessageResult(string msg) { return View("Message",(object)msg); }
这篇关于视图或主人未找到或没有视图引擎支持搜索到的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!