Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Nancy whit Owin and WebForms

There is a method for esclude aspx page from pipeline in the use nancy.Owin in a old webform site project not compiled?

When I configure nancy the post-back and the request is an aspx page the post-back is deleted because nancy delete it and recall the page.

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

    app.UseStageMarker(PipelineStage.MapHandler);
}

The options.PerformPassThrough wipe the post-back content and call the page. For not post-back is ok but in post-back elaboration this present an infinite loop.

How to configure NancyFx for not wipe post-back in passtrought option?

like image 966
Davide Castronovo Avatar asked Jan 11 '18 10:01

Davide Castronovo


1 Answers

I'have modified the nancy official 1.4 sources to esclude from .aspx and other page from pipeline, returning the request postback whitouth delete it. You can try this modify here .

  • File modified: Nancy/src/Nancy/Owin/NancyMiddleware.cs
  • Here te code to apply at line 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);
    
like image 141
Davide Castronovo Avatar answered Nov 09 '22 19:11

Davide Castronovo