문제

I have an existing website using forms authentication with Sql provider. Now i am trying to integrate with another website and use their authentication mechanism. I am already able to validate a user and trying to silently login the user into my application. Here is the code for "silent" login:

if (user != null) // logged in!
{
    IPrincipal principal = new MyPrincipal(user);
    FormsAuthentication.SetAuthCookie(user.ScreenName, true);

    HttpContext.Current.User = principal;

    Response.Redirect("~/Default.aspx");
}

and it works with the exception that Forms Authentication overrides the HttpContext.Current.User by the time i make it "default.aspx". Is there a way to bypass forms role and membership providers?

도움이 되었습니까?

해결책

If you are using a custom principal, the custom principal must be established on every request to the web server; it's not persisted. Adding code to reload it in global.asax would resolve it. Others have created an HTTP module to do this too.

HTH.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top