Fixed code sample (#8475)

Fixed code to retrieve the IHubContext from middleware
pull/8480/head
David Fowler 2018-09-10 07:28:11 -07:00 committed by GitHub
parent d10fb0f151
commit dd507467f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -40,9 +40,8 @@ Access the `IHubContext` within the middleware pipeline like so:
```csharp
app.Use(next => (context) =>
{
var hubContext = (IHubContext<MyHub>)context
.RequestServices
.GetServices<IHubContext<MyHub>>();
var hubContext = context.RequestServices
.GetRequiredService<IHubContext<MyHub>>();
//...
});
```