Is it possible to maintain url when redirecting to a classic asp page from a controller?
When migrating a site from classic asp to MVC, I have a problem that not all controllers are implemented yet. For those not implemented, I would like to serve up a classic asp page (e.g. / product.asp? Id = 123) while keeping the url / product / 123 nice. For this, I implemented a dummy ProductController that returns a RedirectResult to a classic asp url. But this changes the url in the browsers navbar. The requirement has this that the URL must always be clean (mvc), although the page has not yet been fully migrated.
If it is not possible to do this with a dummy controller, what would be the alternative to solve this problem?
Thanks in advance!
a source to share
I can think of two ways to do this:
- In the product controller, execute the page
product.asp?id=123
and return HTML withReturn Content(..)
- Add a dummy product view and from there read
product.asp?id=123
through Ajax and replace the HTML
But both are cumbersome and may not work if you need post
from a page
You can also use URL Rewriter , which does not change the browser url (I have never used one, so I cannot recommend)
My recommendation is to stick with the old url until you migrate to MVC, then redirect from the old url to the new one inglobal.asax
a source to share
Probably the simplest solution would be to use Server.Transfer which, unlike Response.Redirect, leaves the requested URL as it is.
I'm standing fixed: On Server.Transfer it is not possible to navigate from the .aspx page to the .asp page.
However, Server.TransferRequest can be used , but this requires IIS7 with built-in pipeline mode.
ASP.NET Placeholder Site Page
<% Server.TransferRequest("Index.asp", true); %>
ASP landing page
<%@ language="vbscript" %>
<% Response.Write(Request.QueryString("msg")) %>
Using
http://yoursite/Index.aspx?msg=Hello%20World!
a source to share