Nancy
Nancy copied to clipboard
NancyFx not working on .Net Core 3
-
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");
}
}
}
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.
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.
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