NancyFx / Nancy

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

Nancy.Hosting.Self .Net Core compatibiliy #2858

Closed nologinatgit closed 6 years ago

nologinatgit commented 6 years ago

Description

I have created an empty .Net Core ASP.NET project and tried to use Nancy as a self hosted platform. I added the following NuGet packages:

Steps to Reproduce

I created the following code:

  public class Program
  {
    public static void Main(string[] args)
    {
      var uri =
         new Uri("http://localhost:3579");
      using (var host = new NancyHost(uri))
      {
        host.Start();

        Console.WriteLine("Your application is running on " + uri);
        Console.WriteLine("Press any [Enter] to close the host.");
        Console.ReadLine();
      }

      //BuildWebHost(args).Run();
    }   
  }

I start and works yet I have a warning that says:

Package Nancy.Hosting.Self 2.0.0-clinteastwood is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Nancy.Hosting.Self 2.0.0-clinteastwood supports: net452 (.NETFramework,Version=v4.5.2)

Does it mean that I can't create a .Net Core project with self hosting?

System Configuration

khellang commented 6 years ago

Does it mean that I can't create a .Net Core project with self hosting?

No, it just means that you can't use Nancy.Hosting.Self. It's based on HttpListener, which is Windows-specific and HTTP.SYS. If you want to use self-hosting on .NET Core, you should use Kestrel. See https://github.com/NancyFx/Nancy/tree/master/samples/Nancy.Demo.Hosting.Kestrel

dlwiii commented 4 years ago

The Kestrel demo is in .Net Framework, not Core. An example in Core is the Owin demo here:

https://github.com/NancyFx/Nancy/tree/master/samples/Nancy.Demo.Hosting.Owin