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

查看:35
本文介绍了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.

如果我在调试项目时采用完全相同的链接并将域更改为指向 localhost,则电子邮件确认正常.

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 网站(我无法远程调试).当确认失败时,我已经输入了一些代码以通过电子邮件发送给我(这样我就可以看到它试图确认的用户 ID 和代码),并且我已经验证了它在 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天全站免登陆