2017-09-21 22 views
-3

enter image description hereRouteConfig不工作

在運行Visual Studio中的項目;我收到錯誤,如附圖所示。

public static void RegisterRoutes(RouteCollection routes) 
{ 
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

    routes.MapRoute(
     name: "Default", 
     url: "{controller}/{action}/{id}", 
     defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
     //Attendance, Timetable 
    ); 
} 

我把斷點放在左括號上。但它不起作用。 這個問題發生在1小時前。 請告訴我解決方案來解決問題。因爲這個項目計劃儘快發佈。 通過期待一個很好的解決方案,Sibin

+0

什麼是不工作? - 這只是標準的默認路線。 –

+0

先生,我把斷點放在左括號「public static void RegisterRoutes(RouteCollection routes){」,但是在運行項目時,斷點不起作用。 RouteConfig.cs不起作用 – Sibin

+0

在'HomeController'中顯示'Index()'方法 –

回答

0

確保您有一個名爲HomeController控制器,命名爲Index一個ActionResult和同一個view

還要檢查你的Global.asax.cs,它必須包含以下代碼

protected void Application_Start() 
    { 
     RegisterRoutes(RouteTable.Routes); 
    }