ASP.NET MVC Page Won't Load and says “The resource cannot be found”

前端 未结 21 1728
猫巷女王i
猫巷女王i 2020-12-09 14:51

I am having a problem where I try to open my ASP.NET MVC application but I get the ASP.NET error page which says this:

Server Error in \'/\' Applicati

21条回答
  •  一向
    一向 (楼主)
    2020-12-09 15:42

    I found the solution for this problem, you don't have to delete the global.asax, as it contains some valuable info for your proyect to run smoothly, instead have a look at your controller's name, in my case, my controller was named something as MyController.cs and in the global.asax it's trying to reference a Home Controller.

    Look for this lines in the global asax

    routes.MapRoute(
       "Default", // Route name
       "{controller}/{action}/{id}", // URL with parameters
       new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
    

    in my case i had to get like this to work

        new { controller = "My", action = "Index", id = UrlParameter.Optional }
    

提交回复
热议问题