a have a problem with ASP.net MVC url routing. I have created this route (it is first route in my RegisterRoutes method:
routes.MapRoute(
"Activate",
"Account/Activate/{username}/{key}",
new { controller = "Account", action = "Activate", username = "", key = "" },
new { username = @"([a-z0-9\.-]+)", key = @"([a-z0-9\.-]+)" }
);
but when i try to go tu URL like this:
http://localhost:63779/acount/activate/test/hLMqWJrwp1dK5xTqbGkP5kzUNQ4
it returns 404 error
(with UrlParameter.Optional I’ve got the same result)
The problem is that your regular expression is incorrect. Use the following:
The regex shown will match a string containing any word character (\w is the same as [A-Za-z0-9_]) or a dot, which has no spaces or other characters.
UPDATE
After testing the route and copying it into my answer, I forgot to change the controller value to “Account”. I have updated the route above.