What is Routing:
Routes maps controllers names and their actions names. It is used to create user friendly URL.To setup startup page just like web forms. The routing system lets you create any pattern of URLs you desire and express them in a clear and concise manner.
Map Route Functions. It has collections of routes and invokes routes.
Need of Routing:
Old URL pattern:
www.OnlineShop.com/Mobiles.aspx?catId=8
www.OnlineShop.com/Mobiles.aspx?catId=9
www.OnlineShop.com/Mobiles.aspx?catId=15
MVC application:
www.OnlineShop.com/Mobiles/Samsung
www.OnlineShop.com/Mobiles/Motorola
www.OnlineShop.com/Mobiles/Micromax
Benefits :
- SEO friendly Application : Simplify URL
- Non hackable URL’s: It’s not returning actual file name. No physical file
- Prevents from inaccessible and secured files access
- Ignore routes are used to prevent specific routes like web.config, XML file, Image file etc.
routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);