错误如下:未找到视图“LoginRegister”或其主视图,或者没有视图引擎支持搜索的位置。搜索了以下位置:
〜/视图/MyAccount/LoginRegister.aspx
〜/视图/MyAccount/LoginRegister.ascx
〜/视图/共享/LoginRegister.aspx
〜/视图/共享/LoginRegister.ascx
〜/Views/MyAccount/LoginRegister.cshtml
〜/Views/MyAccount/LoginRegister.vbhtml
〜/Views/Shared/LoginRegister.cshtml
〜/视图/共享/LoginRegister.vbhtml
实际上我的浏览页面是~/Views/home/LoginRegister.cshtml
所以我做什么
and my RouteConfig
is
public 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 }
);
}
}
当心如果您的模型类型是 String因为View(string, string)的第二个参数是masterName,不是模型。您可能需要使用 object(model) 作为第二个参数来调用重载:
不正确 :
protected ActionResult ShowMessageResult(string msg)
{
return View("Message",msg);
}
正确的 :
protected ActionResult ShowMessageResult(string msg)
{
return View("Message",(object)msg);
}
或(由 bradlis7 提供):
protected ActionResult ShowMessageResult(string msg)
{
return View("Message",model:msg);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)