user603007
user603007

Reputation: 11794

asp.net mvc 4 default route not specified?

I am looking at setting up a custom route in my mvc 4 application without default parameter defaults (http://www.asp.net/mvc/tutorials/controllers-and-routing/creating-custom-routes-cs)

I modified it slightly:

routes.MapRoute(
            "Blog",                                           // Route name
            "Archive/{entryDate}"                            // URL with parameters
);

the problem is I am getting an error when hitting :

http://localhost:80/Archive/12-25-2009

The matched route does not include a 'controller' route value, which is required.

Upvotes: 1

Views: 1468

Answers (1)

Simon Whitehead
Simon Whitehead

Reputation: 65087

You need to supply a Controller that this route will hit.

routes.MapRoute(
    "Blog",                                           // Route name
    "Archive/{entryDate}",                        // URL with parameters
    new { controller = "Archive", action = "Entry" }
);

Without that, the route doesn't know what Controller your request should be "routed" to. That is because your default route appears to be missing.. which will fall back to your home controller generally.

Upvotes: 4

Related Questions