0

I have created an MVC 5 application (following the Create an ASP.NET MVC 5 App with Facebook and Google OAuth2 and OpenID Sign-on tutorial) and uncommented the line:

app.UseGoogleAuthentication();

Everything works fine. I can login using Google. I then change the project properties to host the application under my local IIS server (instead of the default IIS Express). The Google login no longer works. The line:

var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

in ExternalLoginCallback always returns a null, whereas under IIS Express loginInfo is populated. This means the browser is just bounced back to the Login page. I'm running on Windows 8.1.

I have seen other people having issues with null exceptions, I don't get any. I have restarted IIS. I have rebooted my machine and still I get the same result.

Piers Lawson
  • 747
  • 2
  • 5
  • 18

2 Answers2

2

I have just managed to solve this for a project I am working on as detailed on my blog. The solution seems to be to either turn off Session state

<system.web>
  <sessionState mode="Off"/>
</system.web>

or to ensure that users have a value in their Session before the external login is performed,

[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
    //Ensure Session has at least one value
    Session["EnableExternalAuth"] = true;

    return View();
}

There is an Owin cookie issue/bug which is probably the root cause

and the following StackOverflow questions are also related:

Community
  • 1
  • 1
agilejoshua
  • 2,848
  • 1
  • 21
  • 30
  • Fantastic, the dummy session value worked a treat. Amazing that it is still a bug in the template but kudos to Tomas Dolezal for finding the work around. – Piers Lawson Aug 03 '14 at 19:43
0

See the Technovert article where they discuss adding a location permission subsection to the web.config file.

This solves some of the issues anyway

John Davidson
  • 637
  • 5
  • 11