override Application_PostAuthenticateRequest

Topics: Web Client Software Factory, User Forum
Sep 28, 2007 at 9:16 AM
Edited Sep 28, 2007 at 9:17 AM

How can I override Application _ PostAuthenticateRequest in global.asax in a WCSF solution to add roles for the authenticated user? I am doing forms auth against a sql database and then want to secure using the web.config as usual so need to add roles to my user. It seems, though, that the only sensible method available for override is Application _ PostRequestHandlerExecute. Can I just perform the usual principal creation and addition of roles in there?

As a side note, has anyone ever had VS 2005 stop having intellisense in the App_Code folder? It's driving me mad!


Oct 16, 2007 at 11:16 PM

You can add an event handler and subscribe to the PostAuthenticateRequest event of the HttpApplication class in the Application_Start method.
First you will need to create a class that inherits from WebClientApplication and override the Application_Start method. The following code show this:

namespace Extensions
    public class CustomWebApplication : WebClientApplication
        protected override void Application_Start(object sender, EventArgs e)
            this.PostAuthenticateRequest += new EventHandler(CustomWebApplication_PostAuthenticateRequest);
            base.Application_Start(sender, e);
        private void CustomWebApplication_PostAuthenticateRequest(object sender, EventArgs e)
            //TODO: Add your logic here.
Also, you must change the Inherits property in the Global.asax file to use your new class:

<%@ Application Language="C#" Inherits="Extensions.CustomWebApplication" %>
Please let me know if this helps.

Mariano Converti

Oct 17, 2007 at 10:29 AM
Hi Mariano,

Thanks for that, that's a good way to approach it. What I don't understand though is why the WCSF developers thought fit to remove most of the events in there in the first place.