Email Verification Error Invalid AspNet Identity Token

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

  • Works fine in localhost and qa. Tested ok for SSL on localhost.

  • Production Failure (using SSL). Creating a token from WCF and checking in MVC fails.

  • Creation and verification in the same application.

How does this invalid token error happen? Does web.config have anything to do with this?

+1
source share
1 answer

Found a problem.

These were application pools in IIS. I used a different application pool for WCF and MVC applications. Now I put it in the same application pool and it works fine.

Additional information: For those who have problems, and my solution does not fix the problem, you can try machineKey .

http://gunaatita.com/blog/Invalid-Token-Error-on-Email-Confirmation-in-Aspnet-Identity/1056

PS. I almost always find the answer on my own after I posted it on stackoverflow. Thanks.

+2
source

Source: https://habr.com/ru/post/1241527/


All Articles