33

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).

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

Any guidance is greatly appreciated.

Thank You

John
  • 1,852
  • 4
  • 26
  • 49
  • 3
    Though I can't be 100% certain, I believe that will have to be implemented by hand. – Mike Perrenoud Oct 10 '13 at 12:10
  • 1
    Yes, If it was not clear that is what I was asking, how to do it with ASP.net Identity – John Oct 10 '13 at 12:12
  • 1
    You mentioned you were surprised it wasn't included. I was only confirming the fact that you'd have to do it by hand. I'm not offering a solution - if I were I'd answer the question. – Mike Perrenoud Oct 10 '13 at 12:14
  • Take a look towards the bottom for the Email Confirmation section http://www.codeproject.com/Articles/313153/ASP-NET-MVC-reCAPTCHA-and-Email-Confirmation – Paul Zahra Oct 10 '13 at 12:26
  • 3
    I think u can use @Paul Zahra 's answer and this blog http://kevin-junghans.blogspot.in/2013/10/customizing-aspnet-identity-in-mvc-5.html to get what you need..It shows to customize the user profile in ASP.NET Identity in MVC5 app.Kevin also stated he will try to post about email confirmation in his next article. but i think you can find the solution by connecting this article with Paul's answer. – hridya pv Oct 22 '13 at 08:08
  • 2
    @hridyapv, Kevin has now posted that article for email confirmation and it works great. http://kevin-junghans.blogspot.in/2013/10/adding-email-confirmation-to-aspnet.html – Josh McKearin Nov 04 '13 at 11:07
  • If you are willing to experiment with Identity 2.0 -pre, email and SMS confirmation, amongst many other useful features (such as deletion) have been included in the implementation http://blogs.msdn.com/b/webdev/archive/2014/02/11/announcing-preview-of-microsoft-aspnet-identity-2-0-0-beta1.aspx – xingyu Feb 27 '14 at 21:45

3 Answers3

18

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 here in 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.AspNetIdentity There 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.

Kevin Junghans
  • 17,475
  • 4
  • 45
  • 62
  • Hi, I could not see any documentation whether the UserManager.GenerateEmailConfirmationTokenAsync in new ASP.NET identity automatically inserts the generated code to the users table? Do I have to save the token separately after creating the token? I have tried it and it didn't save.I am trying to check whether its the default behaviour or something in my code – Rohith Nair Aug 26 '14 at 15:52
3

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

https://devblogs.microsoft.com/aspnet/announcing-preview-of-microsoft-aspnet-identity-2-0-0-alpha1/

Tim
  • 7,746
  • 3
  • 49
  • 83
  • 2
    Nuget has the official release now: https://www.nuget.org/packages/Microsoft.AspNet.Identity.Core/2.0.0 – Miro J. Apr 25 '14 at 18:38
0

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:

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.

Andy Brown
  • 5,309
  • 4
  • 34
  • 39
  • 5
    This doesn't actually do anything though. It still signs the user in and will allow them to sign in without confirming their email. – maembe Dec 27 '16 at 23:05
  • To prevent the actual login see the following answer: https://stackoverflow.com/questions/38419883/prevent-users-without-confirmed-email-from-logging-in-asp-net-mvc-web-api-identi/38423392#38423392 – Chris Owens Aug 20 '18 at 04:38
  • Where have you setup sender email, password, server, port? where have you implemented the service for the email. Nothing is explained. – Sracanis Jun 01 '20 at 10:52