Redirect to ReturnUrl after successful cookie authentication in Owin, Katana & Nancy

一笑奈何 提交于 2019-12-03 13:33:18
Steve Godbold

Have you tried Response.AsRedirect("/"); or GetRedirect("/"); on NancyContext

Using your code sample:

public class LoginModule : NancyModule
{
    public LoginModule()
    {
        Post["login"] = p =>
        {
            var name = Request.Form.name;
            var auth = Context.GetAuthenticationManager();
            var claims = new List<Claim> {new Claim(ClaimTypes.Name, name)};
            var id = new ClaimsIdentity(claims, Constants.AuthenticationType);

            auth.SignIn(id);

            return Response.AsRedirect(p.Request.Query.RedirectUrl);
        };
     }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!