Syed Umar Ahmed
Syed Umar Ahmed

Reputation: 5962

Route an aspx url to MVC controller

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

Upvotes: 4

Views: 2445

Answers (2)

Khalid
Khalid

Reputation: 194

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 }
 );

Upvotes: 4

Moe Bataineh
Moe Bataineh

Reputation: 1080

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 }
        );

Upvotes: 6

Related Questions