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

前端 未结 21 1717
猫巷女王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:39

    I got the same error while building a MVC application.
    In my case it happened because I forgot to add the string "Controller" in my controller name.

    Error With

    public class ProductType : BaseController
    {
        public ProductType()
        {
        }
    }
    

    Resolved

    public class ProductTypeController : BaseController
    {
        public ProductTypeController ()
        {
        }
    }
    
    0 讨论(0)
  • 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 }
    
    0 讨论(0)
  • 2020-12-09 15:44

    Open your Controller.cs file and near your public ActionResult Index(), in place of Index write the name of your page you want to run in the browser. For me it was public ActionResult Login().

    0 讨论(0)
提交回复
热议问题