Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Application Start without using Global.asax

I'm developing a plugin like application for a web site. Due to requirements it will live in the same physical path and the same application pool as the main web site which I do not have the source code for. So they both share the same Web.config and some other dependencies.

I need to set a license for a third party dependency at application start, but I have no way of accessing the code behind for Global.asax as that code is owned by a different company.

So, is there an alternate way of appending events to Application Start without involving Global.asax or is my only solution to inherit/extend the current Global.asax?

like image 722
zidar Avatar asked Dec 23 '22 08:12

zidar


1 Answers

You can use a HTTPModule:

public class MyModule : IHttpModule
{
    #region IHttpModule Members

    public void Dispose()
    {
    }

    public void Init(HttpApplication context)
    {
        ...
    }

    #endregion
}

web.config

<httpModules>
  <add name="MyModule" type="MyNamespace.MyModule, MyAssembly" />
</httpModules>
like image 165
Arthur Avatar answered Dec 29 '22 14:12

Arthur