i trying validate token using action in controller.
in 1 action, generate token , redirect action.
string token = await usermanager.generateemailconfirmationtokenasync(user.id); string userid = httputility.urlencode(user.id); string emailtoken = httputility.urlencode(token); return redirecttoaction("testtoken", new { userid = userid, emailtoken = emailtoken });
in testtoken
action, decode attributes , try confirm it, result
false, error invalid token.
string decodeduserid = httputility.urldecode(userid); string decodedtoken = httputility.urldecode(emailtoken); identityresult result = await usermanager.confirmemailasync(decodeduserid, decodedtoken);
if i, instead of redirecting testtoken
action, put code right after first, validation succeeds... wrong?
if @ examples provided in following links
create secure asp.net mvc 5 web app log in, email confirmation , password reset (c#)
account confirmation , password recovery asp.net identity (c#)
you see not encode
string token = await usermanager.generateemailconfirmationtokenasync(user.id); return redirecttoaction("testtoken", new { userid = user.id, emailtoken = token });
or decode user id or token.
public async task<actionresult> testtoken(string userid, string emailtoken ) { //... code removed brevity identityresult result = await usermanager.confirmemailasync(userid, emailtoken ); //... code removed brevity return view(); }
Comments
Post a Comment