ASP.NET assemblies - running under a specific URL

Discussion in 'ASP .Net' started by Leszek Taratuta, Nov 3, 2004.

  1. Hello,

    I have an ASP.NET application as an assembly running on a specific website.
    I would like to prevent anybody from using the application if they copy the
    assembly to another website. The application should not start when copied to
    a website other than specified.

    The question is how to secure the assembly so it works only on a specified
    What namespace in .NET framework should I use?
    What technique should I utilize?

    Thanks for any help,
    Leszek Taratuta
    Leszek Taratuta, Nov 3, 2004
    1. Advertisements

  2. There are two possible approaches for this:

    1. Screen request URLs for a permitted list of sites (by DNS name and IP).
    2. Implement a licensing mechanism.

    Of the two, #1 is easier to implement, but it's also much less flexible than
    licensing. You should also keep in mind that both approaches are reasonably
    simple to bypass by decompiling, modifying, then recompiling your
    assemblies, and anyone who is willing to ignore contractual and/or licensing
    agreements to copy your application is very likely willing to ignore similar
    injunctions against decompliation.

    That said, if you want to use the simplest implementation, adding a
    BeginRequest event handler to screen for acceptable server addresses would
    do the trick. For example, if you had an application that should only run
    on the Microsoft site, you might want to use something like the following:

    protected void Application_BeginRequest(Object sender, EventArgs e)
    bool allowRequest;

    switch (Request.Url.Host.ToLower())
    case "localhost":
    case "":
    case "":
    case "":
    allowRequest = true;
    allowRequest = false;

    if (!allowRequest) throw new HttpException(404, null);

    Nicole Calinoiu, Nov 7, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.