0

I am trying to set a authetication request based on my ticket created in login.aspx but for some reason I getting an error the code is as follows

    protected void Application_AuthenticateRequest(object sender, EventArgs e)
    {
        // Create an Identity object
        FormsIdentity identity = (FormsIdentity)Context.User.Identity;
        // When the ticket was created, the UserData property was assigned a
        // pipe delimited string of role names.
        string[] roles = identity.Ticket.UserData.Split(new char[] { ',' });
        String userData = identity.Ticket.UserData;
        // This principal will flow throughout the request.
        GenericPrincipal principal = new GenericPrincipal(identity, roles);
        // Attach the new principal object to the current HttpContext

    }

enter image description here

c-sharp-and-swiftui-devni
  • 3,743
  • 4
  • 39
  • 100

1 Answers1

0

You have to go from Application_AuthenticateRequest(), to the next function in the pipeline:

Application_AuthorizeRequest(object sender, EventArgs e)

At this stage windows authentication should be completed becouse at Application_AuthenticateRequest() it is still null. Basic information about pipeline order can be found here and nice visualization diagram here

Also as fallows if you are runnig with IIS 7 and asp.net 4.0 you should call all login requests inside:

Application_PostAuthenticateRequest() (object sender, EventArgs e)

as in example

Community
  • 1
  • 1
Sebastian 506563
  • 6,980
  • 3
  • 31
  • 56