views:

52

answers:

2

While migrating a site from a classic asp to MVC, I'm having the problem that not all controllers are implemented yet. For those which are not implemented, I'd like to serve the classic asp page (say /product.asp?id=123) while maintaining the nice url /product/123. To accomplish this I implemented a dummy ProductController which returns a RedirectResult to the classic asp url. But that changes the url in the browsers navigation bar. Requirement has it, that the urls should always be a clean (mvc) one, eventhough the page has not yet been fully migrated.

If this can't be done using a dummy controller, what would be an alternative option to solve this problem?

Thanks in advance!

+2  A: 

I can think two ways to do it:

  1. In the product controller, execute the product.asp?id=123 page and return the HTML using Return Content(..)
  2. Add a dummy view product and from there, read the product.asp?id=123 via Ajax and replace the HTML

But both are cumbersome and might not work if you need to post from the page

You can also use a URL Rewriter that does not change the browser URL (I have never used it, so can't recommend)

My recommendation is to stick with the old URL as long as you don't migrate them to MVC, and then perform the redirection from the old URL to the new one in global.asax

Eduardo Molteni
Thanks. I guess, I'll try to implement one of the free UrlRewriting components mentioned in the blog-posting behind your link.
Matthias
Just now ScottGu have posted something new about Rewriting. Hope it helps. http://weblogs.asp.net/scottgu/archive/2010/04/20/tip-trick-fix-common-seo-problems-using-the-url-rewrite-extension.aspx
Eduardo Molteni
It can be done using Server.TransferRequest on IIs7 with integrated pipeline mode. See my updated answer.
Filburt
A: 

Probably the simplest solution would be to use Server.Transfer which in contrast to Response.Redirect leaves the requested URL as it is.

I stand corrected: It is indeed not possible to Server.Transfer from a .aspx page to an .asp page.


It is however possible using Server.TransferRequest but it requires IIS7 with integrated pipeline mode.

ASP.NET Placeholder Page

<% Server.TransferRequest("Index.asp", true); %>

ASP Target Page

<%@ language="vbscript" %>
<% Response.Write(Request.QueryString("msg")) %>

Usage

http://yoursite/Index.aspx?msg=Hello%20World!
Filburt
I think that you can't `Server.Transfer` to an ASP classic from a ASP.net page.
Eduardo Molteni