WebService中,如何修改HttpResponse.StatusCode

连风 连风 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
WebService方法如下:

public ExampleModel FindAModel(string _id)
{
HttpResponse response = HttpContext.Current.ApplicationInstance.Response;
response.StatusCode = (int)HttpStatusCode.Unauthorized;
response.StatusDescription = "this is a test!";
response.ContentType = "application/json";
return this.Buffer.FirstOrDefault(p => p.ID.Equals(_id));
}

通过工具查看http返回信息,始终是200 ok
HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Fri, 30 Mar 2012 10:07:41 GMT
X-AspNet-Version: 4.0.30319
Content-Length: 34
Cache-Control: private
Content-Type: application/json; charset=utf-8
Connection: Close


请问:我如何才能修改其值呢?
...全文

相关推荐

评论 17
收藏 已收藏
分享
返回顶部
连风
.NET社区 62,271 成员 668,968 内容