asp.net Identity - GeneratePasswordResetTokenAsync Method When Passed to View Token Changes? -
when use usermanager generate password reset token, once gets passed razor view token changing.
an example is:
var resettoken = await usermanager.generatepasswordresettokenasync(userid); if (registersuccess) { var model = new resetmodel { token = resettoken, userid = userid }; return this.view(model); }
i can see when debugging value of reset token is
aqaaancmnd8bfderjhoawe/cl+sbaaaamfru4hd3q0wlianc7dsekqaaaaacaaaaaaadzgaawaaaabaaaab1q/fgovgsh+0ssllyskrfaaaaaasaaacgaaaaeaaaafmvfxsy24plghsoiqfo/yraaaaayll/7e8qwrh5jefhmkgvhne4czm3tfwvl4lre7jhm/i6ckktdlohofac054ergy7btwtv9om7ila3f/ti90idbqaaabafr8pdgz2ebxq/sgw0qvp6pqlwg==
but once rendered on view has changed
aqaaancmnd8bfderjhoawe/cl+sbaaaamfru4hd3q0wlianc7dsekqaaaaacaaaaaaadzgaawaaaabaaaacdu0qqzkc65kqa58ift5nbaaaaaasaaacgaaaaeaaaaggy5flp6xtr7cgzkvronnpaaaaaha1ip7uxqd6kskbwbofdxm1kaznoekiytsad6/zkejock5cdd1fk/jdxks0rx9rheqtjpzkzeemh5hi3//clixqaaaajfoivgvuhooxtmzmey+allzmifq==
the view code looks like:
@html.hiddenfor(x => x.token)
i'm @ total loss whats going off here. know whats happening? why token changing once it's rendered view?
you need add url-encoding token if passed urls:
var resettoken = await usermanager.generatepasswordresettokenasync(userid); resettoken = system.web.httputility.urlencode(resettoken);
otherwise browser messes special symbols can present in token.
if print in view, need turn off htmlencoding via html.raw
:
<input type="hidden" value="@html.raw(model.token)" name="token" />
Comments
Post a Comment