Why does OWIN need Authentication mode="forms" RRS feed

  • Question

  • User-557362475 posted

    I haven't found a clear answer for this after searching but why do all the stackover flow answers to OWIN OAuth question say to set the

    <authentication mode="Forms">

    and then to

    <modules runAllManagedModulesForAllRequests="true"> <!--added-->
    <remove name="FormsAuthentication" />
    <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" /> <!--added-->

    I'm following this tutorial:

    but they never show that they have successfully login using OWIN, while I get an error for Request.IsAuthenticated = false in the _loginpartial.cshtml page.

    The AccountController's ExternLoginCallBack works fine, and shows Success, but then the webApp still doesn't show the user is authenticated.

    public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
        var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
        if (loginInfo == null)
            return RedirectToAction("Login");
        // Sign in the user with this external login provider if the user already has a login
        var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: true);
        switch (result)
            case SignInStatus.Success:
                return RedirectToLocal(returnUrl);
            case SignInStatus.LockedOut:
                return View("Lockout");
            case SignInStatus.RequiresVerification:
                return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
            case SignInStatus.Failure:
                // If the user does not have an account, then prompt the user to create an account
                ViewBag.ReturnUrl = returnUrl;
                ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
                return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email });

    Any thoughts? Do we really need to set the Authentication mode to forms if we're using OWIN?

    Original question here:

    Monday, February 1, 2016 3:45 PM