我正在使用 Owin、Katana 和 Nancy 来托管一个带有需要身份验证部分的简单站点。注意我也在使用 nuget 包 - Nancy.MSOwinSecurity
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = Constants.AuthenticationType,
LoginPath = new PathString("/Login"),
});
app.UseNancy();
这是我的模块代码
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);
// redirect how????
return View["index"];
};
}
}
我的提交表格
<form name="login" action="/login" method="post" accept-charset="utf-8">
<ul>
...
</ul>
</form>
现在我希望在成功登录后重定向到 ReturnUrl -
例如 Login?ReturnUrl=%2Fblah%2blahblah
似乎没有像表单身份验证那样的重定向方法,而且查询字符串参数属性为空。