Skip to content

Instantly share code, notes, and snippets.

@esskar
Last active August 29, 2015 14:03
Show Gist options
  • Save esskar/b4450c8e11eb7e17cb6b to your computer and use it in GitHub Desktop.
Save esskar/b4450c8e11eb7e17cb6b to your computer and use it in GitHub Desktop.
SignalR and MiddleWare
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);
}
}
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