Pregunta

I have an existing MVC 5 project which is happily using forms authentication and a custom membership provider behind the scenes and I'd like to add external logins (Google/Facebook etc) to this.

I've tried following posts such as this Microsoft example however they all seem to cover creating a new project using the wizard. I've I created a Startup.cs and Startup.Auth.cs class exactly as the tutorial shows (with all the correct dependencies) however they don't fire when the app starts for some reason, unlike the wizard example which fires after the app_start global.asax method. I've tried matching the config etc but that doesn't seem to work either.

Is there something I'm missing in terms of how to wire these classes in?

Due to this problem I'm tempted to use an AuthConfig.cs file and Microsoft.AspNet.Membership.OpenAuth as I have before but I'm not sure if this is now considered evil in MVC5?

Any help would be appreciated.

¿Fue útil?

Solución

It would appear this is all part of Microsoft's new Identity framework which basically replaces Membership.

Following a mixture of this tutorial for adding Identity from scratch and this tutorial about doing a migration from Membership to Identity I managed to get Startup firing properly.

HOWEVER - if you are reading this and are in a similar situation I would think carefully and evaluate the Identity framework against all of the alternatives available both from MS and other sources before jumping in. At the time of writing, I would would say that the Identity framework isn't currently ready to be used in a production application and others seem to agree. Looking at the road map I've no doubt it'll get traction once the features are padded out, however at the moment it requires too much work for it to be workable for me.

Looking at my requirements I will be sticking with my custom membership provider and will add my external logins on top using DotNetOpenAuth.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top