I want to map a route like this:
mysite.com/username
in ASP.NET MVC 3 application; How can I do it, please?
Thanks to all, regards
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.
Maybe add custom route at the very beginning that would inherit from System.Web.Routing.Route, and override method
where you would check in db using indexed column.
Just add some not nullable constraint object like
so that route object will process constraints.
Before hitting database maybe make some heuristics whether this can be username. Remember you cant have user same as controller (when having default action), so you want to limit that somehow. Pay attention if that wont hurt year performance, but you probably dont have many routes with single value after slash.
This is how you can do this.
This add at the beginning.
Works for me in both ways, generating and incomming.