locked
DelegatingHandler - HttpStatusCode error RRS feed

  • Question

  • User647458646 posted

    Hi, 

    I am currently getting a "The name 'HttpStatusCode' does not exist in the current context" error, on the following highlighted code below:

    public class AuthHandler2 : DelegatingHandler
        {
             private const string BasicAuthResponseHeader = "WWW-Authenticate";
            private const string BasicAuthResponseHeaderValue = "Basic";
    
            [Inject]
            iUser repository { get; set; }
    
             public AuthHandler2(iUser repository)
            {
              this.repository = repository;
            }
    
             private Task<HttpResponseMessage> Unauthorized(HttpRequestMessage request)
             {
                 var response = request.CreateResponse(HttpStatusCode.Unauthorized);
                 response.Headers.Add(BasicAuthResponseHeader, BasicAuthResponseHeaderValue);
    
                 var task = new TaskCompletionSource<HttpResponseMessage>();
                 task.SetResult(response);
                 return task.Task;
             }
        }

    I have a the same code in class called public class AuthHandler : DelegatingHandler, but it seems to be working fine their.  

    Could someone please advise. 

    Thanks 

    Friday, May 2, 2014 8:02 AM

Answers