I have a service project (WCF) and MVC project which uses same database, to handle service part for Mobile and Interface part. I have to set up email confirmation on both. <
I found the solution. The problem was the DataProtectionProvider
.
On MVC, it was getting from:
public static ApplicationUserManager
Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
var dataProtectionProvider = **options.DataProtectionProvider**;
On WCF, it was from:
var provider = new Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider("ASP.NET");
So I used same as WCF in MVC:
var dataProtectionProvider = new Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider("ASP.NET");
Also, the key point is:
HttpUtility.UrlEncode
to encode the token code.Example:
var code = UserManager.GenerateEmailConfirmationToken(appuser.Id);
var callbackUrl = string.Format("http://MVCSite/Account/ConfirmEmail?userId={0}&code={1}", HttpUtility.UrlEncode(appuser.Id), HttpUtility.UrlEncode(code));
Update
For anyone trying to host multiple projects, you need one of these two things to be the same to still be able to use the confirmation code:
Email Confirmation Error Invalid Token AspNet Identity
http://gunaatita.com/Blog/How-to-Generate-Machine-Key-using-IIS/1058