Arif YILMAZ
Arif YILMAZ

Reputation: 5866

cannot set Default route for MVC project

I cannot set the Default Route for my MVC project. When I run the project, it goes to the address http://localhost:7555/ and it give the "HTTP ERROR 404" but if I enter the url http://localhost:7555/Default , it goes to the Default page. But I want users to go the Default page even if they dont enter http://localhost:7555/Default.

here is my Route in Global.asax

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

what am I supposed to do?

Upvotes: 1

Views: 633

Answers (1)

ediblecode
ediblecode

Reputation: 11971

Generally if you want this functionality you would have a HomeController that just works out of the box with the route config. You've chosen instead to have DefaultController instead - so we need to work it a little differently:

routes.MapRoute(
    "Default", 
    "{action}/{Filtre}", 
    new { controller = "Default", action = "Index", Filtre = UrlParameter.Optional } 
);

Upvotes: 1

Related Questions