I’m creating a website with internationalization and what I want to do is to support URL with this format:
"{country}/{controller}/{action}"
How can I tell the routing engine that {country} should be set using a session variable?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do this with a custom Controller Factory. Start with your route:
I handle the culture by overriding the
GetControllerInstancemethod ofDefaultControllerFactory. The example is below:You can here get the value from session instead of hardcoding it as I did.
and register it on the Global.asax: