خرید بک لینک

Vote count: 0

In the default Visual Studio web project for MVC5, you'll find the following code:

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
switch (result)
{
    case SignInStatus.Success:
        retu RedirectToLocal(retuUrl);
    case SignInStatus.RequiresVerification:
        var userId = await SignInManager.GetVerifiedUserIdAsync(); // I added this!
        retu RedirectToAction("SendCode", new { RetuUrl = retuUrl, RememberMe = model.RememberMe });
    // other cases
}

At this point, SignInManager.GetVerifiedUserIdAsync() retus null. On the next controller action in the chain, however:

public async Task<ActionResult> SendCode(SendCodeViewModel model)
{
    if (!await SignInManager.SendTwoFactorCodeAsync(model.SelectedProvider))
    {
        retu View("Error");
    }
    retu RedirectToAction("VerifyCode", new { Provider = model.SelectedProvider, RetuUrl = model.RetuUrl, RememberMe = model.RememberMe });
}

It retu the user Id.

I know that partially signed-in users are tracked through the process via cookie, so I presume this postback is necessary to set the cookie and thus pick up the userId. But I want to be able to send my users straight to the verification code screen which I can't do without an Id.

Is there any way round this, forcing the cookie to be set programatically?

asked just now

- - , .
.

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 23 تير 1395 ساعت: 20:56

صفحه بندی