当前上下文中不存在名称“HttpStatusCode” [英] The name 'HttpStatusCode' does not exist in the current context
本文介绍了当前上下文中不存在名称“HttpStatusCode”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到一个名称'HttpStatusCode'在当前上下文中不存在错误,在下面的突出显示的代码中:
I am 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;
}
}
我在另一个名为'public class AuthHandler:DelegatingHandler'的类中有相同的代码,但似乎工作正常他们。
有人可以请一些建议。
谢谢
I have a the same code in another class called 'public class AuthHandler : DelegatingHandler', but it seems to be working fine their.
Could someone please advice.
Thanks
推荐答案
你错过了使用System.Net的?
/ ravi
Are you missing ausing System.Net
?
/ravi
这篇关于当前上下文中不存在名称“HttpStatusCode”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文