ASP.NET MVC - Catch All Route And Default Route

后端 未结 8 1975
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 04:15

In trying to get my application to produce 404 errors correctly, I have implemented a catch all route at the end of my route table, as shown below:

 routes.M         


        
8条回答
  •  情书的邮戳
    2020-11-28 04:54

    //this catches all  requests
    routes.MapRoute(
        "Error",
        "{*.}",
         new { controller = "PublicDisplay", action = "Error404" } 
    );
    

    add this route at the end the routes table

提交回复
热议问题