NancyFx / Nancy

Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono
http://nancyfx.org
MIT License
7.16k stars 1.47k forks source link

NancyFx not working on .Net Core 3 #2994

Open rock85mx opened 4 years ago

rock85mx commented 4 years ago

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");
    }
}

}

klym1 commented 4 years ago

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.

RamkiPannerselvam commented 4 years ago

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.

moh-hassan commented 4 years ago

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