I'm developing an application that will replace a much older one. The older one has been in use for many years, and utilises querystring paramaters to reference certain things, for
http://example.com/view_object.asp?obj=Banana
I'd like to re-direct this to my ObjectController's Index action, while passing the querystring value "Banana", in order to allow the older URLs to continue functioning with the new system.
So, the new URL would be:
http://example.com/Object/Banana
I thought this would be simple, by using routes.MapRoute, but i run into an issue where i can't use the ? character.
How do i go about doing this?
Here is what was tried:
routes.MapRoute(
name: "OldObjectRoute",
url: "view_object.asp?obj={object}",
defaults: new { Controller = "Object", action = "Index", object = UrlParameter.Optional }
);
EDIT: So, based on the suggestion below that this is a duplicate, i did try what was suggested. I came up with:
routes.MapRoute(
name: "OldObjectRoute",
url: "view_object.asp{OldList}",
defaults: new { Controller = "Object", action = "Index", OldList = UrlParameter.Optional }
);
In my controller i have an optional string "OldList" now, that is expecting values from this - and adjusts the querystring to remove the query, and return the correct data based on the object that was requested.
However, now it simply does not work - I'm informed by the IIS Web Core "ASPClassic" handler that a 404 occurs when using MapRequestHandler. Sounds like it's now interpretting this as a request for a Classic ASP page? Does anyone know how to stop this happening?