ASP.NET Identity 2-UserManager.ConfirmEmail在生产中失败 [英] ASP.NET Identity 2 - UserManager.ConfirmEmail Fails In Production

查看:104
本文介绍了ASP.NET Identity 2-UserManager.ConfirmEmail在生产中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在ASP.NET MVC应用程序中设置了OWIN(包括电子邮件确认).创建帐户后,我会收到一封包含确认我的电子邮件链接的电子邮件.当我访问链接时,出现无效令牌"错误.

I've set up OWIN in an ASP.NET MVC app (including email confirmation). When an account is created I get an email containing a link to confirm my email. When I visit the link, I get the "Invalid Token" error.

如果我使用完全相同的链接,而在调试项目时将域更改为指向本地主机,则电子邮件确认正常.

If I take that exact same link and instead change the domain to point at localhost while debugging the project, the email confirms just fine.

该项目正在部署到Azure网站(我无法进行远程调试).我已经扔了一些代码以在确认失败时通过电子邮件发送给我(这样我可以看到userId和它试图与之进行确认的代码),并且我已经验证了它试图在Azure中与之进行验证的代码是相同的.为该用户生成的代码.似乎没有任何编码问题或类似问题.

The project is being deployed to an Azure Web Site (which I can't remote debug). I've tossed in some code to email me when confirmation fails (so that I can see the userId and code it was trying to confirm with) and I've verified that the code it's attempting to verify with in Azure is the same as the code that's generated for that user. It doesn't appear to be any encoding problems or anything like that.

我用Google搜索了无数东西,然后空了出来.而且由于无法远程调试问题的发生位置(在Azure网站中),所以我几乎没有想法.

I've Googled a bazillion things and come up empty. And since I can't remote debug the problem where it's happening (in the Azure Web Site) I'm pretty much out of ideas.

这里可能出什么问题了?

What could be going wrong here?

推荐答案

好的,这里有一些尝试.

OK, here are a couple of things to try.

如果您有一个域而不是确认来生成cookie,则您需要在此之间共享一个机器密钥.

If you have a different domain generates the cookie than does the confirmation, you need to share a machine key between then.

如果您使用DpapiDataProtectionProvider()作为提供程序,则可能会遇到应用程序池名称未知的问题.您必须在启动时对其进行不同的配置,然后使用在选项中设置的应用程序池名称.我不必这样做,因为我使用的是aws,可以只设置应用程序池名称.您还必须将应用程序池的LoadUserProfile设置设置为true.

If you are using DpapiDataProtectionProvider() as your provider, you may have a problem in that your app pool name is unknown to you. You have to configure it differently at startup and then use the app pool name that gets set in your options .. somehow! I didnt have to do that because I am using aws and could just set the app pool name. You also have to set the app pool's LoadUserProfile setting to true.

希望有帮助!

这篇关于ASP.NET Identity 2-UserManager.ConfirmEmail在生产中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆