4

I simply wants to route a URL which is not in the MVC project. Like

http://mysite.com/Parents/default.aspx?ID=xxx

TO

http://mysite.com/accounts/login

with the ID

2 Answers 2

6

I think something like this would work.

routes.MapRoute(
            name: "Default",
            url: "Parents/default.aspx?ID={id}",
            defaults: new { controller = "Accounts", action = "Login", id = UrlParameter.Optional }
        );
1
  • routes.MapRoute( name: "Default", url: "Parents/default.aspx", defaults: new { controller = "Accounts", action = "Login", id = UrlParameter.Optional } its says - The resource cannot be found /parents/default.aspx Aug 29, 2013 at 14:14
4

If you want to redirect all .aspx pages to redirect at "accounts/login" then do like below

routes.MapRoute(
   "Page",
   "{name}.aspx",
   new { controller = "Accounts", action = "Login", id = UrlParameter.Optional }
 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.