#2 Customize URL in MVC

you can customize Request URL in Route.Config.


routes.MapRoute(
 "Search",
 "{controller}/{name}",
 new{ controller = "Process",action ="Find", name = ""} 
 );

In the above example Search is the URL Route Request  which gets mapped to Controller of Process with an Action Method Find which accepts name as parameter (Request URL and Controller name can be different)

1.The Routing Request url can be of any name,it need not match with controller , but you must define the corresponding controller with its action in the MapRoute Method. 

2.There is no mandatory rule that the URL should be of {Controller}/{action},it can be simply {Controller} and again you must define the respective controller with action in MapRoute.

 


	

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s