derekclee
asked on
Error checking type for HttpContext.Current.User.Identity
This code was converted from VB.NET and I'm getting the following errors:
System.Web.HttpContext.Cur rent' is a 'property' but is used like a 'type'
and
Cannot implicitly convert type 'System.Security.Principal .IIdentity ' to 'System.Web.Security.Forms Identity'. An explicit conversion exists (are you missing a cast?)
System.Web.HttpContext.Cur
and
Cannot implicitly convert type 'System.Security.Principal
public void doAuthentication()
{
if (HttpContext.Current.User != null)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
if (typeof (HttpContext.Current.User.Identity) is FormsIdentity)
{
FormsIdentity id = HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
string strUserData = ticket.UserData;
string[] strRoles = strUserData.Split(',');
HttpContext.Current.User = new GenericPrincipal(id, strRoles);
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER