Skip to content

Instantly share code, notes, and snippets.

View Adrian10988's full-sized avatar

Adrian Adrian10988

View GitHub Profile
public class ApiAuthorize : AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
filterContext.HttpContext.Items.Add("unauthorized", true);
}
}
protected void Application_EndRequest()
{
var context = new HttpContextWrapper(this.Context);
//check if we have an unathorized value in the dictionary
if(context.Items.Contains("unauthorized"))
{
context.Response.Clear();
context.Response.StatusCode = 401;
}
public class ApiAuthorize : AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
var response = filterContext.HttpContext.Response;
response.Clear();
response.StatusCode = 401;
response.End();
}
public class ApiAuthorize : AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
filterContext.HttpContext.SuppressFormsAuthenticationRedirect = true;
}
}
@Adrian10988
Adrian10988 / gist:5641441
Last active December 17, 2015 16:49
First blog post
namespace WelcomeToMyLair
{
public class Greeting
{
public Greeting()
{
EntryDetection.OnUserVisit += NewUserDetected;
}
void NewUserDetected(UserInfo info, EventArgs e)