This project has moved and is read-only. For the latest updates, please go here.
1

Closed

somtime I cannot authenticate by Owin at first login by facebook

description

I used OWIN Auth to authenticate on my asp.net mvc 5 website. It run great on localhost, i can login and get user's info from facebook. However, I have a bug when run on IIS server. Sometime, I can't login, cannot get loginInfo from method Request.GetOwinContext().Authentication.AuthenticateAsync(DefaultAuthenticationTypes.ExternalCookie);

It return NULL. I must re-login then success. I viewed, it logined on second-time.

I research many time on internet , but i still cannot found solution for this issue. Can you help me resolve it?

Pls, reply information as soon as possible ! Thanks so much.
Closed Mar 2 at 10:49 PM by mgirgin

comments

thanhtd wrote Sep 1, 2015 at 2:53 AM

I try with your solution: Reconfigure the CookieAuthenticationMiddleware to write directly to System.Web's cookie collection. However it cannot resolve this issue. I still cannot login success at first time.
Can you help to show me what is wrong?

Thanks for your support!

My config:

app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),

            CookieManager = new SystemWebCookieManager()
        });
public class SystemWebCookieManager : ICookieManager
{
    public string GetRequestCookie(IOwinContext context, string key)
    {
        if (context == null)
        {
            throw new ArgumentNullException("context");
        }
        .....