Nancy icon indicating copy to clipboard operation
Nancy copied to clipboard

NancyFx not working on .Net Core 3

Open rock85mx opened this issue 5 years ago • 3 comments

  • I just to migrate mi proyect from net core 2.2 to 3.0, and nancy dosnt work.

  • Nancy version: 2.0

  • Microsoft.Owin: 3.0

  • Startup.cs

public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseOwin(b => b.UseNancy()); }

using Nancy;

namespace WebApplicationCore { public class Index : NancyModule { public Index() { Get("", args => Root()); }

    public Response Root()
    {
        return Response.AsText("Server up");
    }
}

}

rock85mx avatar Nov 15 '19 18:11 rock85mx

I've had exactly the same problem! It appeared that starting from .Net Core 3 it is forbidden to use Kestrel's synchronous API by default (the sync API is apparently used by Nancy as a middleware). So the fast workaround for this issue is to allow synchronous API in Kestrel settings:

var host = new WebHostBuilder()
      .UseKestrel(o =>
      {
      o.AllowSynchronousIO = true;
      })

But, of course, it would be much better if somebody made a PR and let Nancy Owin wrapper use async api.

klym1 avatar Nov 15 '19 20:11 klym1

Even I was facing the same issue when I use the latest version of .NET CORE 3.1 and the nancy version is 3.1.0. After a lot of research, I have found this answer. The above solution is working fine.

The alternative solution is, you can downgrade the nancy version to 2.2.0 if you want.

RamkiPannerselvam avatar Jan 07 '20 06:01 RamkiPannerselvam

a wiki page Hosting Nancy on ASP .NET Core 3.1 (using Kestrel) describe in detail how to use NancyFx with ASP.NET CORE 3.1

moh-hassan avatar Apr 01 '20 08:04 moh-hassan