I tried to implement my own AuthorizeAttribute for my REST API that I’ve built with the WCF Web API Preview 6.
Unfortunately only the constructor gets called, but non of the methods. Am I missing something with the registration?
[BasicHttpAuthorize]
[WebGet(UriTemplate = "")]
public IEnumerable<Supertext.API.Order> Get()
{
And this is my super simplified code.
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class BasicHttpAuthorizeAttribute: AuthorizeAttribute
{
public BasicHttpAuthorizeAttribute()
{
}
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return true;
}
public override void OnAuthorization(AuthorizationContext filterContext)
{
//do the authorization
}
}
But as I said, neither the AuthorizeCore nor the OnAuthorization method is ever called.
Any ideas?
The
AuthorizeAttributeand action filters in general are ASP.NET MVC specific artifacts. They have nothing to do with WCF. Decorating a WCF operation contract with it won’t have much effect.