Question

We still have a lot of incoming urls pointing to our old .asp pages. The new .aspx pages are called the same as the old .asp pages, and accept mostly the same values, so they are pretty much interchangeable. Unfortunately we still get both POST and GET requests to the old .asp pages. We handled these .asp requests in our Asp.Net 2.0 app by adding this in our web.config (system.webserver section):

    <handlers>
        <add name="ASPClassicForRedirectToASPX"
             path="*.asp"
             verb="*"
             modules="IsapiModule"
                scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
             resourceType="Unspecified"
             preCondition="classicMode,runtimeVersionv4.0,bitness32" />
    </handlers>

and then checking in BeginRequest if the url ends with .asp, and if it does, do a RewritePath to .aspx

Now we have migrated to asp.net 4.0 and I started to wonder if there is a better way to handle this, and still keep backwards compatibility with the old .asp urls?

Was it helpful?

Solution

what i would do if not allready the case is something like that in the BeginRequest instead of url rewrite (when possible) :

Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","New-url");
Response.End();

using a 301 permanent redirect you will make sure that all crawlers and stuff will change their link to the right one that should reduse the calls u get to your .asp pages by a lot. other than that you are stuck with the old direct links to your asp pages at some point im guessing you will have to let them go. Cant support old stuff forever even tho that would be awesome :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top