Classic ASP using MVC routing on IIS7

2019-08-09 07:26发布

问题:

After taking the first hurdle, I found something amusing.

Direct access (i.e. /OLD/ASP/myFile.asp) to the page works (well, no, but it returns a plausible ASP error ;) ).

However, trying to route the page such as:

routes.MapPageRoute(
        "OldASP",
        "Page/{*id}",
        "~/OLD/ASP/myFile.asp",
        false,
        new RouteValueDictionary(),
        new RouteValueDictionary(new { @id = @"\d+" })
    );

Returns the magnificant There is no build provider registered for the extension '.asp'. error (which was originally solved for direct access as described above)

How can I keep routes and ASP? (tried this to no avail)

回答1:

I'd be surprised if you can use Classic ASP pages within a .net mvc project. You can certainly use .aspx and .asp pages in the same website

Your best bet is probably to use web.config and the rewrite module

http://www.surfingsuccess.com/asp/iis-url-rewrite.html#.UtaDhkA15tA

One thing to watch out for, if you're using asp.net MVC then there is potential for conflicts between web.config and MVC's own routing system

Take a look at this question IIS URL Rewrite ASP



回答2:

If you have a Classic ASP application and you are looking to use the MVC routing you may try to create your own Router for the "nice URLs". The idea is to use IIS Error 404 handler to parse the nice URL. I had projects (both VBScript and JScript) entirely written in Classic ASP with "nice URL" and custom router. Check this: http://www.codeproject.com/Articles/706216/Classic-ASP-MVC-for-dynamic-JavaScript-pages