locked
Writing a custom http handler for .asp extension RRS feed

  • Question

  • User1085970526 posted

    I have a site that I am moving from classic asp to asp.net. The site has been around for quite a few years, and there are a great deal of valuable links pointing to the .asp pages on the site. I would love to keep those links pointed to relevant parts of the new site, so I want to implement a custom http handler.

     I wrote a handler to redirect using the search-engine-friendly 301 code instead of the 302 used by response.redirect.


    public class RedirectHome : IHttpHandler
    {
       bool IHttpHandler.IsReusable
        {
            get { return true; }
        }

        void IHttpHandler.ProcessRequest(HttpContext ctx)
        {
            ctx.Response.Status = "301 Moved Permanently";
            ctx.Response.AddHeader("Location", "/default.aspx");
        }
    }
     

    I also modified web.config as follows

            <httpHandlers>
                <add verb="GET" path="nonExistentPage.asp" type="RedirectHome" />
            </httpHandlers>

     I can't seem to get IIS to respond to this handler. If I change the path to nonExistentPage.aspx it works fine.

    I went into the Application configuration on IIS on my win2k3 server and mapped the .asp extention to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll, but had no luck.

     
    The alternative is very ugly - I would need to have dummy .asp page in my nice, clean new site for every page in the old site. I'd much rather deal with this through a handler.

    Thanks,

    John

     

    Saturday, November 4, 2006 10:43 AM

All replies