0

I am really really really new to ASP MVC and I want to add a default controller to the projcet.
I searched for this topic but none of theme helped to me like :
ASP.NET MVC Routing with Default Controller
and ...

How can add a default controller to the project to prevent application error?
When I browse the http://localhost:8688/, I see an error: The resource cannot be found.

Community
  • 1
  • 1
Soroush Khosravi
  • 887
  • 2
  • 11
  • 30

1 Answers1

1

Normally when you create a new MVC based application there's a default setting in the Global.asax.cs file:

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

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

So the default controller would be called HomeController in the Controllers subfolder. and the default action would be Index.

Check if you have that in the Global.asax.cs and also have a HomeController class.

Likely you selected to create an empty MVC application which doesn't put a HomeController class in it and gives an error when you hit F5 (what's not there can't be executed).

Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61