I'm upgrading an ASP.Net MVC4 site to MVC5, and implementing the new OWIN Authentication methods in the process.
I've copied over the action methods from the Account controller on a blank MVC5 project.
The problem is, when I click an external provider button (e.g. Google) I just get redirected back to the login page again. The second time I click it, I do get taken to the Google account page, but then the browser gets redirected to the Account/External login page.
What's going on?
Check the
<authentication>
element in your web.config file. It is probably still sayingChanging it to
<authentication mode="None">
should fix the problem.For good measure, remove the FormsAuthentication module from your webserver modules section:
The problem is that the FormsAuthentication module looks out for any responses with a 401 (Unauthorised) code and changes them into a redirect request to your login page.
I had the same issue and Samuel Jack's answer did help me, but I had to make a slight change.
For me, adding the
under the "handlers" section did not work. Instead, I had to add it under the "modules" section as below and the issue was resolved.
Here is how my web.config looks.
Note that in my case, there already was a
in my web.config but that did not help solve the issue. I don't know how it got there so I left it alone.
Hope this helps.
I had this exact problem for 1 day straight, but sometimes I have some bad days and my attention to details is low.
But my problem was a bit awkward. My external logins were fine for like few months and suddenly stopped working and I didn't touched that code at all however my webconfig was...
Luckily I figured this out before posting a question I was about to write and made me see that location tag.
I have no idea why it worked in the first place then got broken later. I haven't updated any reference, did literally nothing to this for weeks.