我想讓該網站的默認頁面爲Login.cshtml。我得到例外:Asp.net Mvc區域路由問題
Error: The view 'LogIn' or its master was not found or no view engine supports the searched locations. The following locations were searched:
我有2個領域。結構如下所示。
我routeconfig如下所示。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace Portal.Web
{
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 = "Home", action = "LogIn", id = UrlParameter.Optional },
namespaces: new[] { "Portal.Web.Areas.Management" }
);
}
}
}
我的global.asax.cs如下圖所示:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
namespace Portal.Web
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
}
`你有什麼建議嗎?
該網址沒有明確的答案。你最終做了什麼?默認:new {area =「management」,controller =「Home」,action =「LogIn」將默認值更改爲:{controller =「Home」,action =「LogIn」,id = UrlParameter.Optional} 「,id = UrlParameter.Optional}''? – Robert
沒有任何直接解決方案的鏈接,這對任何人都不值得。 – Syska
我有同樣的問題,我解決了我的問題,解決我的Web應用程序的命名空間。我將我的控制器從無區域移動到管理區域,並且沒有工作,當我調整它所有類的名稱空間時 – renefc3