aspnet / ServerTests

[Archived] Tests for Helios, WebListener and Kestrel. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
21 stars 13 forks source link

[Annoucement] WebListener 1.0.0-rc2 is now available on nuget.org #42

Closed Tratcher closed 7 years ago

Tratcher commented 8 years ago

The following packages have been released today on nuget.org:

Microsoft.AspNetCore.Server.WebListener.1.0.0-rc2-final Microsoft.Net.Http.Server.1.0.0-rc2-final

WebListener is a Windows HTTP server built on the Http.Sys kernel mode driver. It exposes a number of Http.Sys features previously only availabe in IIS.

Kernel mode:

WebSockets (Windows 8)

WebListener is supported for edge deployments because it's built on the existing Http.Sys HTTP stack. Note AspNetCoreModule is not compatible with WebListener for use behind IIS/Express, Kestrel must continue to be used in that scenario.

These packages are supported on Windows 7 and Windows Server 2008 R2 and later.

Usage with ASP.NET Core (Microsoft.AspNetCore.Server.WebListener):

        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseWebListener(options =>
                {
                    options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.NTLM;
                    options.ListenerSettings.Authentication.AllowAnonymous = false;
                })
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }

Direct usage (Microsoft.Net.Http.Server):

            var settings = new WebListenerSettings();
            settings.UrlPrefixes.Add("http://localhost:8080");

            using (WebListener listener = new WebListener(settings))
            {
                listener.Start();

                while (true)
                {
                    var context = await listener.AcceptAsync();
                    byte[] bytes = Encoding.ASCII.GetBytes("Hello World: " + DateTime.Now);
                    context.Response.ContentLength = bytes.Length;
                    context.Response.ContentType = "text/plain";

                    await context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
                    context.Dispose();
                }
            }
campersau commented 8 years ago

Are there any public changelogs available for these packages?

304NotModified commented 8 years ago

Could you tell us in which cases we should use this?

Tratcher commented 8 years ago

If you're on Windows and want to expose your server directly to the internet (Kestrel is not certified for direct exposure), or you need any of the features listed above.

Tratcher commented 8 years ago

@campersau not at the moment, though there is a prior announcement for API breaking changes. https://github.com/aspnet/ServerTests/issues/39

aminebizid commented 8 years ago

NTLM Authent not working:

image

 public static void Main(string[] args)
        {            

            var host = new WebHostBuilder()                
                 .UseWebListener(options =>
                 {
                     options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.NTLM;
                     options.ListenerSettings.Authentication.AllowAnonymous = false;                     

                 })
                 .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }

PS: If I remove Kestrel, MVC stops routing

Tratcher commented 8 years ago

You need to remove UseKestrel and UseIISIntegration and not run in IIS/Express, only self-host. See the comments above about AspNetCoreModule not being compatible with WebListener.

 public static void Main(string[] args)
{            
            var host = new WebHostBuilder()                
                 .UseWebListener(options =>
                 {
                     options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.NTLM;
                     options.ListenerSettings.Authentication.AllowAnonymous = false;                     

                 })
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseStartup<Startup>()
                .Build();

            host.Run();
}
justdmitry commented 8 years ago

If you're on Windows and want to expose your server directly to the internet (Kestrel is not certified for direct exposure)

Where can I read more details about Kestrel, WebListener and other "expose to internet" certification?

Tratcher commented 8 years ago

@blowdart, do we have docs around edge certification?

blowdart commented 8 years ago

Considering there's no "expose to internet" certification, no, we don't.

Tratcher commented 8 years ago

@justdmitry @blowdart this is the official doc: https://docs.asp.net/en/latest/fundamentals/servers.html#kestrel

Tratcher commented 8 years ago

@justdmitry also https://github.com/aspnet/Docs/issues/1903

NeelBhatt commented 8 years ago

I have tried to convert it into blog post so that more people can know about this.

https://neelbhatt40.wordpress.com/2016/10/08/weblistener-is-now-on-nuget-a-net-core-server/

tdykstra commented 8 years ago

That blog post is well done - I've created a proposed outline for a new doc about WebListener that follows a similar organization and expands on it, see https://github.com/aspnet/Docs/issues/1827

NeelBhatt commented 8 years ago

Thanks a lot @tdykstra.

I will update my post by taking points from above comment.

tdykstra commented 8 years ago

Moving the doc outline to the Docs repo issue for this doc -- https://github.com/aspnet/Docs/issues/1827

Tratcher commented 8 years ago

WebListener 1.0.0 has now released to nuget.org. There are no significant changes from rc2.