Skip to content

Instantly share code, notes, and snippets.

@changhuixu
Created January 23, 2020 16:04
Show Gist options
  • Save changhuixu/5319ba495f813100136265cdd2991b01 to your computer and use it in GitHub Desktop.
Save changhuixu/5319ba495f813100136265cdd2991b01 to your computer and use it in GitHub Desktop.
ASP.NET Core basic authentication attribute filter
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class BasicAuthAttribute : TypeFilterAttribute
{
public BasicAuthAttribute(string realm = @"My Realm") : base(typeof(BasicAuthFilter))
{
Arguments = new object[] { realm };
}
}
@integralsun
Copy link

Compile error:

base(typeof(BasicAuthFilter)
The type or namespace name 'BasicAuthFilter' could not be found (are you missing a using directive or an assembly reference?

What reference is needed here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment