Application_Start problem

Topics: Web Client Software Factory
Aug 21, 2007 at 12:06 PM

I need to verify that the current user (Windows Authentication) that's just started an application exists in the membership table, and if not add the user and assign a default role. To achieve this I've created a custom class inheriting from WebClientApplication, which Global.asax inherits from, and then override Application_Start.

public class HRWebClientApplication : WebClientApplication
protected override void Application_Start(object sender, EventArgs e)
base.Application_Start(sender, e);

// membership management code here

In Global.asax: <%@ Application Language="C#" Inherits="HRWebClientApplication" %>

This works on my local machine, but not on the QA/Prod server. When someone logs onto the application, the code doing the above is not firing.

Any ideas?
Aug 21, 2007 at 4:37 PM
Edited Sep 1, 2007 at 10:09 PM
Application_Start only fires when the application itself starts, not when a user session begins. This probably works on your local dev IIS (Casini) because the site is technically new every time you debug, so the application is just starting. Consider using a different HttpApplication event or perhaps a custom http module to achieve the action you are looking for.

Are you using a forms membership provider or windows membership provider? From your post it sounds as if you may be mixing the two. You may take a look at this MSDN article on the WindowsAuthenticationModule:

Jarod Ferguson