Last active
August 29, 2015 14:03
-
-
Save esskar/b4450c8e11eb7e17cb6b to your computer and use it in GitHub Desktop.
SignalR and MiddleWare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomMiddleWare : OwinMiddleware | |
{ | |
public CustomMiddleWare(OwinMiddleware next) | |
: base(next) { } | |
public override Task Invoke(IOwinContext context) | |
{ | |
try | |
{ | |
if (context.Request.QueryString.HasValue) | |
{ | |
// access the query with context.Request.Query.Get | |
// set a custom user with context.Request.User = new CustomUser() | |
} | |
} | |
catch (Exception ex) | |
{ | |
// handle | |
} | |
return this.Next.Invoke(context); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Startup | |
{ | |
public void Configuration(IAppBuilder app) | |
{ | |
app.Use(typeof(CustomMiddleWare)); | |
app.MapSignalR(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment