forms - Asp.net Identity Email Verifcation Token Not Recognized -


We are using Microsoft's Identity Framework v2.0 in a web form application. All are working well We have decided that we want to add email verification under the new account setup process. If we validate tokens after being created in the same page, then we succeed, but if we try to validate the token on a separate page, then it fails. The process is very simple:

  1. The administrator creates a new account by providing the user's email and name. (We do not support automatic registration.)
  2. The user was received in the email to verify the email to get the link.

Here is the code to generate email verification token:

  var manager = new UserManager (); Var user = new applicationUser () {user name = email address. Text, email = email address. Text, first name = first name Text, last name = last name Text}; Identification Results Results = Manager. Create (user); Var provider = new DpapiDataProtectionProvider (); Manager.UserTokenProvider = New DataProtectorTokenProvider & lt; ApplicationUser & gt; (Provider ("Email Configuration")) {TokenLifespan = TimeSpan.FromHours (24)}; Var strToken = manager.GenerateEmailConfirmationToken (user.Id); // Identified valid token = manager Confirm Email (user.Id, strToken); Stratocon = HTTPPreality.URLNcode (Strotocon.tostring ());  

Note: If we confirm the beginning of the line // identification, then valid token ..., then it succeeds.

Here is the code on VerifyEmail page:

String UserID = Request .QueryString ["id"]. ToString (); String Token Regex = Request .QueryString ["Token"]. ToString (); // recover token = HttpUtility.UrlDecode (recover token); ApplicationUser user = new ApplicationUser (); Var Manager = New UserManager (); User = Manager. FIBID (user ID); Var provider = new DpapiDataProtectionProvider (); Manager.UserTokenProvider = New DataProtectorTokenProvider & lt; ApplicationUser & gt; (Provider ("Email Configuration")) {TokenLifespan = TimeSpan.FromHours (24)}; Identified Valid Token = Manager. Confirm Email (user id, token reexpected);

A valid talk line is not successful in this file. I've confirmed that the string User.Id and Token match exactly in both files, so no URL corruption is running. (This is the reason I commented on the URL code because it is decoding the browser automatically - when I try to decode it does not equal the string before 100% encoding).

That's why I'm sure we're calling the same method (ConfirmEmail) and that both of the passed parameters are exactly the same string. I also know that a token can be validated only once, so I am not trying to use them again after validating them.

Any ideas will be welcomed.

Problem in DpapiDataProtectionProvider - If you use the same example of this class in the formation and validation of tokens, it will work fine.

For any reason, you are not receiving UserManager from the OWin reference according to the VC2013 template?


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -