I have two web applications, WCF and MVC, which use the same database. I am using Aspnet Identity 2.0
When registering a new user, he creates a confirmation token and sends an email to the user. Creating a token, sending e-mail is mainly performed in WCF, verification is performed in the MVC application.
var code = UserManager.GenerateEmailConfirmationToken(user.Id); string.Format("{0}/Account/ConfirmEmail?userId={1}&code={2}", WebsiteUrl, HttpUtility.UrlEncode(user.Id), HttpUtility.UrlEncode(codeId));
I use the same data protection provider
In WCF
var provider = new Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider("MyTestApplication"); UserManager.UserTokenProvider = new Microsoft.AspNet.Identity.Owin.DataProtectorTokenProvider<ApplicationUser>( provider.Create("UserToken")) { TokenLifespan = TimeSpan.FromDays(7) };
In MVC
var dataProtectionProvider = new Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider("MyTestApplication"); manager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("UserToken")) { TokenLifespan = TimeSpan.FromDays(7) }; }
Source: Make ASP.NET Identity 2.0 Email token verification for WCF and MVC
Now to my problem
How does this invalid token error happen? Does web.config have anything to do with this?
source share