使用 Nancy whit Owin 和 WebForms

Use Nancy whit Owin and WebForms

在旧的 webform nancy.Owin 中使用 nancy.Owin 管道中有 esclude aspx 页面的方法 未编译站点项目?

当我配置 nancy post-back 并且请求是一个 aspx 页面时,post-back 被删除,因为 nancy删除它并重新调用页面。

public void NancyConfig(IAppBuilder app)
{
    app.UseNancy(options =>
    {
        options.Bootstrapper = new MyBootstrapper();
        options.PerformPassThrough = (context => context.Response.StatusCode == HttpStatusCode.NotFound);
    });

    app.UseStageMarker(PipelineStage.MapHandler);
}

options.PerformPassThrough擦除post-返回内容并调用页面。因为不是 post-back 是可以的,但是在 post-back 详细说明中,这会出现一个无限循环。

如何在 passstrought 选项中配置 NancyFx 不擦除 post-back?

我已经修改了 nancy 官方 1.4 源以从 .aspx 和管道中的其他页面中排除,返回请求回发而不删除它。 你可以试试这个修改 here .

  • 文件修改:Nancy/src/Nancy/Owin/NancyMiddleware.cs
  • 这里是要在第 82 行应用的代码:

                //Check if the webform is not present inthe path ".aspx"
                //if present move to next
                if (owinRequestPath.ToLowerInvariant().Contains(".aspx")
                || owinRequestPath.ToLowerInvariant().Contains(".asmx")
                || owinRequestPath.ToLowerInvariant().Contains(".ascx")
                || owinRequestPath.ToLowerInvariant().Contains(".ashx")
                || owinRequestPath.ToLowerInvariant().Contains(".asmx")
                || owinRequestPath.ToLowerInvariant().Contains(".asax")
                ) return next.Invoke(environment);