If this is asked before just point me in the right direction I am a OO and MVC newbie. I am following along the MVC Storefront(a little outdated now) where they are talking about routes and adding them to global.asax.cs
My question is this: wouldn't it be better if only 1 route is def开发者_运维知识库ined and after that everything is done programatically?
I don't want the user to navigate using the address bar.
thank you
First of all, if you define only one route in MVC, i.e. /{controller}/{action}/{id} (which is default btw.), the routing mechanism will work perfectly as every action in MVC must be defined in a controller.
Sometimes you may want to have some special routes, like /users/{id}/{username}, like this page has to create routes that make sense to your users and search engines. This is a very interesting approach very difficult to accomplish in ASP.NET (until 4.0).
IMHO there's nothing wrong having logical guessable route names in your application, it looks a lot better than having mysterious long urls with cryptic paths. Letting the user "guess" the urls is not bad at all.
Well,
ASP.NET MVC routing help's you to extend the URL SEO. At same time you will set a rule so that no human can directly access any resource via altering a url.
Thanks! Sandeep Sachan
精彩评论