moztemur
moztemur

Reputation: 981

Asp.NET MVC 4 routing a specific URL to a certain controller



I want to run a certain Asp.NET MVC 4 Controller when an URL -probably irrelevant with the controller name- is entered. For example, if the user opens the address "localhost:3364/abc/def", I want to run the controller with the name, for example, "SugarController". Is it possible, or do I have to start my URL with the word "Sugar"? I know that URL routing can be done by adding some code to Global.asax file in the project. But I don't exactly know how to manage this one.
Thanks in advance.

Upvotes: 1

Views: 746

Answers (1)

bmavity
bmavity

Reputation: 2508

This should work

 routes.MapRoute("Fixed", "abc/def", new { controller = "Sugar", action = "def"});

Upvotes: 3

Related Questions