Does any body knows how to hide some parameters in url?
For example you have a url parameter "culture". It can be "en, fr, it". By default your site renders in "en" culture and we don't wont to show default culture in the URL but in cases of other cultures parameter "culture" must appear in URL.
http://myrendersite.net/barbikueue
http://myrendersite.net/fr/barbikueue
This is same pages in different cultures. How to do what basing on default asp.net mvc routing system?
This will help:
ASP.NET mvc, localized routes and the default language for the user
asp.net mvc localization
Set Culture in an ASP.Net MVC app
You have to register two routes:
Create an
Attribute
that inheritsActionFilterAttribute
:After that create a
BaseController
with the previous created attribute:And all your
Controllers
will inheritBaseController
now, instead ofController
The following RouteConstraint might help,
Use it as,
Here the constraint only works on outbound url and discard the route for candidacy when 'culture' in route information equals to default.
I used the simplest implementation because you have not posted your route code, but the idea should work.
hope this helps.