Zubair
Zubair

Reputation: 389

ASP.NET MVC - Help defining route entry

i want to build a route entry for a url http://example.com/foo which should map to Index(string foo) action method of a controller named User.

At the same time the default Home Controller should not be affected and should work normally

any help is greatly appreciated

Thanks

Upvotes: 0

Views: 86

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

You could try putting this before the default route:

routes.MapRoute(
    "FooRoute",
    "{foo}",
    new
    {
        controller = "Home",
        action = "Index",
        foo = UrlParameter.Optional
    }
);

Upvotes: 0

Related Questions