We are in the process of upgrading our site to .NET and have run across a few issues in regards to old links that are still being used by other sites to direct users to ours. The client has made it clear they do not want any .asp files running on the site,
but yet we have to account for these old asp links and the query strings associated with them. So, after many google searches and many different attempts at using web.config and Custom Errors in IIS. I've come up with a solution, but I'm still not sure it's
the best solution. Our host is very picky about ISAPI and adding API's to their servers so a HttpHandler is pretty much out of the question - but if it's the best way to do it - then perhaps they can be convinced. Here's my solution: I've set IIS to map all
asp requests to the .net dll and even though they are explicitly not handled by ASP.NET - it atleast throws an error out. I catch that in Application_Error and check the raw url to see if the user is requesting either of the files and redirects to the page
that parses the query string: protected void Application_Error(Object sender, EventArgs e) { string URL = Request.RawUrl; if ((URL.IndexOf("item.asp?") > -1) || (URL.IndexOf("enter.asp?") > -1)) { Response.Redirect("redirect.aspx?errorURL=" + Server.HtmlEncode(URL));
} } Pretty simple, but I'm not sure if this is the safest method. If anyone has dealt with this type of situation before I'd love to hear how you solved it. Thanks, Jesse
cooljkaz
Member
32 Points
7 Posts
Redirecting old asp links to new aspx links.
Sep 23, 2003 09:06 PM|LINK
President, OutCoursing, Inc.