A new middleware component provides WebSockets support in ASP.NET Core 1.1. Install the [Microsoft.AspNetCore.WebSockets](https://www.nuget.org/packages/Microsoft.AspNetCore.WebSockets/) package, and add code to the `Configure` method of the `Startup` class:
```
app.UseWebSockets();
```
Your project will then have access to a `WebSockets` property on the `HttpContext` object. You can write your own middleware for the pipeline to interpret and interact with the requests handed to your application by a websocket. You could add this middleware to your configured pipeline with code like the following:
```
app.Use(async (context, next) =>
{
if (context.WebSockets.IsWebSocketRequest)
{
var webSocket = await context.WebSockets.AcceptWebSocketAsync();
await DoSomethingCool(context, webSocket);
}
else
{
await next();
}
});
```
The websocket object has `SendAsync` and `ReceiveAsync` methods. For samples, see the [WebSockets repository](https://github.com/aspnet/WebSockets/tree/dev/samples).