简体   繁体   中英

Mapping classic asp pages to .net in IIS

I'm trying to map requests for classic asp pages to be handled by .net, so that it runs through a custom httpmodule.

In IIS I have remapped asp requests to aspnet_isapi.dll - I'm sure I've done this bit right

Now in my test app I am getting this error:

Server Error in '/TestASPRedirect' Application.
--------------------------------------------------------------------------------

This type of page is not served. 
Description: The type of page you have requested is not served because it has been explicitly forbidden.  The extension '.asp' may be incorrect.   Please review the URL below and make sure that it is spelled correctly. 

Requested URL: /testaspredirect/test.asp

Searching online for this error shows a load of people having problems with cassini, but this is not really relevant, I am testing this on both IIS 5.1 on XP dev machine, and have tested on IIS6 also getting the same error.

I have followed instructions for adding and registering a httphandler (see http://support.microsoft.com/default.aspx?scid=kb;en-us;Q308001 ), but I don't know what to put in the ProcessRequest routine to ensure the request gets passed on. What is the default .net httphandler, can I just map to this in web.config?: so something like:

<httpHandlers>
     <add verb="*" path="*.asp" type="standard.nethttphandler"/>
</httpHandlers>

How do I tell asp.net that it needs to pass ASP requests on and not block?

Actually you are only one step far from the success. Adding following section to your Local website(or virtual directory) web.config file:

<configuration>
...
<system.web>
    <compilation>
        <buildProviders>
            <add extension=".asp" type="System.Web.Compilation.PageBuildProvider"/>
        </buildProviders>
    </compilation>
    <httpHandlers>
        <add path="*.asp" verb="*" type="System.Web.UI.PageHandlerFactory" validate="true"/>
    </httpHandlers>
</system.web>

It looks like the .asp extension is mapped to the HttpForbiddenHandler .

If you're using ASP.NET 1.1 then open the following file:

C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322\\CONFIG\\machine.config

If you're using ASP.NET 2.0 then open this file:

C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\CONFIG\\web.config

Search for " path="*.asp" ", then comment out that line. It'll like something like:

<!-- machine.config/ASP.NET 1.1-->
<add path="*.asp" verb="*" 
     type="System.Web.HttpForbiddenHandler"/>`

<!-- web.config/ASP.NET 2.0-->
<add path="*.asp" verb="*" 
     type="System.Web.HttpForbiddenHandler" validate="true"/>`

Locate the below file:

C:\\WINDOWS\\MICROSOFT.NET\\FRAMEWORK\\<FramworkVersion>\\Config\\web.config

where <FramworkVersion> is folder name:

open it in an XML editor .. (even notepad is fine)

and add below line :

<add path="*.asp" verb="*" type="System.Web.UI.PageHandlerFactory" validate="True"/>

under below XPath:

configuration/system.web/httpHandlers

replace the existing one!

Add below line:

<add extension=".asp" type="System.Web.Compilation.PageBuildProvider"/>

under below XPath:

/configuration/system.web/compilation/buildProviders

Worked like gem for me :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM