Execute code on startup

Jan 22, 2007 at 5:48 PM
In our old app, we used global.asax to execute code to initialize our persistency layer. However, with the WCF, it creates a global.asax that inherits from Microsoft.Practices.CompositeWeb.WebClientApplication, and does not execute the typical Application_Start method. Any suggestions?

thanks
Don


P.S. So far the WCF looks pretty good! Looking forward to working with the page flow software..
Jan 22, 2007 at 7:08 PM
Here is the fix:

1. the global.asax must inherit from Microsoft.Practices.CompositeWeb.WebClientApplication (or else you get a null ref exception)

2. you can override any of the typical global.asax methods, but you must call the base class method at the beginning of your override.

E.g.:

<%@ Application Language="C#" Inherits="Microsoft.Practices.CompositeWeb.WebClientApplication" %>

<script runat="server">

protected override void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup

base.Application_Start(sender, e);

// do stuff

}

void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown

}
}