2

I am maintaining a customer Classic ASP website, and some ASP.NET code was found in a specific place.

I need someone to help me understand the meaning of each line, because I will have to replace this ASP.NET code with Classic ASP functions.

From my understanding, here is what the code performs :

  1. Get the Request.QueryString url, and put it into a variable named str
  2. Redirect (send a HTTP 302) to the Url-Decoded value of str

I would be sure not missing anything else. Is my understanding full and complete ?

Thank you all .NET folks :)

<%@ WebHandler Language="C#" Class="GenericHandler1" %>

using System;
using System.Web;

public class GenericHandler1 : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        string str = context.Request.QueryString.Get("url");
       // context.Response.Redirect( context.Server.UrlDecode(str));
        HttpContext.Current.Response.Redirect(context.Server.UrlDecode(str), false);
    }

    public bool IsReusable {
        get 
        {
            return false;
        }
    }

}
2
  • 1
    This isn’t Classic ASP. Commented Dec 30, 2019 at 13:10
  • Is my understanding full and complete ? yes Commented Dec 30, 2019 at 13:16

1 Answer 1

3

Your understanding is correct. This is a simple HTTP Handler that decodes URLs and redirects the request to the decoded location.

This is not strictly required in many modern sites but it is a hack that can simplify interpreting url parameters if your site does a lot of it from first principals or in scenarios where you believe the original parameters might be double encoded.

To fully replicate the implementation, you probably don't need to replicate this code at all, not in a global sense. Instead look into the web.config or global.asax.cs or if this is more recent look for startup.cs in one of those files should be the registration for this handler, look for any references to GenericHandler1. When you find that code, you will have found the rest of the implementation detail that you may need to consider implementing.


This is a strange thing to ask, "replicate an ASP.Net website in classic ASP". I'm sure you have your business reasons, but have you instead considered upgrading to an OWIN implementation, perhaps with ASP.Net Core? This is usually the easier option if your requirement is to deploy to non IIS host.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your clarifications. And yes, I agree that "migrating ASP.NET to Classic ASP" may seem a little bit odd, but as you guessed it perfectly, that is a business imperative for my client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.