jol*_*olt 9 c# authentication nancy
我对Nancy很陌生,现在正在尝试使用Auth.期待完全实现Forms身份验证.
出于测试目的,我设置了3个模块.
其他模块:
public class OtherModule : NancyModule
{
public OtherModule() : base()
{
// Use global, module level authentication.
this.RequiresAuthentication();
Get["/other"] = _ =>
{
return "Other";
};
Get["/woot"] = _ =>
{
return "Woot";
};
}
}
Run Code Online (Sandbox Code Playgroud)
主要模块:
public class MainModule : NancyModule
{
public MainModule() : base()
{
Get["/yolo"] = _ =>
{
// Use per-route authentication.
this.RequiresAuthentication();
return "#YOLO";
};
}
}
Run Code Online (Sandbox Code Playgroud)
AuthModule:
public class AuthModule : NancyModule
{
public AuthModule() : base()
{
Get["/login"] = _ =>
{
return "To proceed, you must authenticate. [show form]";
};
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我导航到/other和/或/woot,我被重定向到/login- 正如预期的那样.虽然,当我导航到/yolo,应用程序抛出一个Nancy.ErrorHandling.RouteExecutionEarlyExitException,我认为它应该重定向到我/login?returnUrl=seeme.
我已经浏览了github表单auth源,它具有此文件中的行为.我似乎找不到任何重大差异(我的Bootstrapper,我的IUserMapper,我的IUserIdentity).
我的用处不对吗?我应该尝试/捕获它并相应地准备响应吗?这是一个错误吗?
我在自托管环境(Nancy.Hosting.Self)中运行NancyFX ,没有ASP,也没有OWIN.