Reputation: 6483
I have an aspx page Test.aspx. It handles requests like Test.aspx?First=value1&Second=value2&third=value3 How can I use routing to redirect this url to TestController/MyAction?First=value1&Second=value2&third=value3
I know I can create an aspx and perform redirect in it`s page load. But seems ugly and I think it can be done with some custom route.
What I`ve tried was: this solution
but it didnt work for me.
I remember, that Test.aspx should not be on a disk. I don`t have it, and routing is still not working. Have no idea on what can cause this issue.
Upvotes: 1
Views: 856
Reputation: 53191
Have you tried adding a route like the following:
routes.MapRoute(
"Test",
"Test.aspx",
new { controller = "TestController", action = "Show" }
);
Just remember that the route will not work if the Test.aspx
file is still on disk.
Also, ideally you would want to have a permanent redirect so the search engine links etc get updated to point to your new urls.
Upvotes: 2