0

hi
I'm trying to implement a custom forms authentication based on existing objects.
i have created the following classes classes:

[Serializable]
public class MyIdentity : IIdentity
{
    // my custom members and properties
}

[Serializable]
public class MyPrincipal : IPrincipal
{
    // my custom members and properties
}

i'm using the following code for my authentication:

identity = new MyIdentity("name");
principale = new MyPrincipal(identity, arrRoles);
HttpContext.Current.User = principale;

the problem is that after the page is redirected the following cast doesn't work

MyPrincipal user = (MyPrincipal)HttpContext.Current.User;

it throws a cast exception. what am i doing wrong here ?

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by emilio
0

i found my mistake.
i needed to deserialize my ticket in global.asax event
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.