用于外部登录的MVC 5 ReturnURL

时间:2014-01-20 15:15:19

标签: asp.net-mvc authentication asp.net-mvc-5 owin

有没有人知道如何/在哪里设置传递给的returnUrl参数:ASP.Net MVC 5应用程序上的AccountController:

// POST: /Account/ExternalLogin
    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public ActionResult ExternalLogin(string provider, string returnUrl)
    {
        // Request a redirect to the external login provider
        return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }));
    }

1 个答案:

答案 0 :(得分:1)

这通常在查询字符串中进行,假设您需要“管理”页面的授权登录用户,因此当用户单击管理页面时,它会重定向到登录页面并返回URL设置到“管理”页面。

具体来说,它是CookieHandler / Cookie OWIN中间件,它正在重定向到登录页面并自动将当前Uri附加到returnUrl的查询字符串中。