C# 使用 MVC 5 和 Asp.net Identity 进行电子邮件确认

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19295236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 14:40:47  来源:igfitidea点击:

Email Confirmation with MVC 5 and Asp.net Identity

c#asp.netasp.net-mvcasp.net-mvc-5asp.net-identity

提问by John

I have been searching, but have not found any documentation on how to implement Email confirmation with MVC 5 using the new ASP.net Identity. There does not seem to be any documentation on this topic (that I could find).

我一直在搜索,但没有找到任何关于如何使用新的 ASP.net 标识通过 MVC 5 实现电子邮件确认的文档。似乎没有关于这个主题的任何文档(我可以找到)。

Has anyone solved this yet? I am very surprised that this is not included by default in the default MVC 5 project.

有没有人解决过这个问题?我很惊讶这在默认的 MVC 5 项目中没有默认包含。

Any guidance is greatly appreciated.

非常感谢任何指导。

Thank You

谢谢你

回答by Kevin Junghans

I have written a step-by-step article on how to add email confirmation when using ASP.NET Identity. You can get the source code herein the project folder AspNetIdentity\AspNetIdentityRefApp. I have also created a service layer that encapsulates ASP.NET Identity, making it easier to incorporate in new MVC 5 applications and mimics the WebSecurity API used by SimpleMembership. You can get that class library from AspNetIdentity\SimpleSecurity.AspNetIdentityThere is also reference app for using this library in AspNetIdentity\SimpleSecurity.AspNetIdentity.RefApp. The class library and reference app also show how to implement password reset using a token and basic authentication on Web API's.

我写了一篇关于如何在使用 ASP.NET Identity 时添加电子邮件确认的分步文章。您可以在项目文件夹AspNetIdentity\AspNetIdentityRefApp 中获取源代码。我还创建了一个封装 ASP.NET Identity 的服务层,使其更容易集成到新的 MVC 5 应用程序中,并模仿 SimpleMembership 使用的 WebSecurity API。你可以从类库AspNetIdentity \ SimpleSecurity.AspNetIdentity也有参考应用程序使用这个库AspNetIdentity \ SimpleSecurity.AspNetIdentity.RefApp。类库和参考应用程序还展示了如何在 Web API 上使用令牌和基本身份验证来实现密码重置。

回答by Tim

For ASP MVC 5 you can now try the pre-release of Identity 2 which has email confirmation and password reset...

对于 ASP MVC 5,您现在可以尝试预发布的 Identity 2,它具有电子邮件确认和密码重置...

http://blogs.msdn.com/b/webdev/archive/2013/12/20/announcing-preview-of-microsoft-aspnet-identity-2-0-0-alpha1.aspx

http://blogs.msdn.com/b/webdev/archive/2013/12/20/annoucing-preview-of-microsoft-aspnet-identity-2-0-0-alpha1.aspx

回答by Andy Brown

I installed identity framework 2 in an MVC website in May 2016, and it includes email confirmation, although it's commented out initially. Here's what to look for in the account controller:

我于 2016 年 5 月在 MVC 网站中安装了身份框架 2,它包括电子邮件确认,尽管最初已被注释掉。以下是要在帐户控制器中查找的内容:

enter image description here

在此处输入图片说明

So when a user registers, you can uncomment the code to send them an email. If you've got a good understanding of the MVC model, the rest should be relatively straightforward.

因此,当用户注册时,您可以取消注释代码以向他们发送电子邮件。如果您对 MVC 模型有很好的理解,其余的应该相对简单。