WebService中,如何修改HttpResponse.StatusCode
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
请问:我如何才能修改其值呢?
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
请问:我如何才能修改其值呢?
...全文
相关推荐
HttpClient 调用WebService示例
一个使用HttpClient访问WS 的例子,包含相关jar包
IOS 程序使用urlconnection连接服务器方法
介绍了各种IOS程序连接服务器的方法,开发IOS程序必备文档
CISP-CSE注册云安全工程师备考资源包基础教程
随着云计算技术的普及,云安全已成为网络安全领域的核心议题。CISP-CSE(注册云安全工程师)认证由中国信息安全测评中心颁发,旨在培养具备云安全专业知识和实践能力的实战型人才。本教程将结合"CISP-CSE注册云安全工程师备考资源包",系统性地为您梳理云安全的核心知识体系,并提供实战案例分析,助您高效备考。
绘图模拟:在冲动环境中固定时间的示例 附matlab代码.rar
绘图模拟:在冲动环境中固定时间的示例 附matlab代码.rar
基于规则的电动汽车混合能源管理系统,采用MATLAB、Simulink、Simscape Electrical和Stateflow。.zip
1.版本:matlab2014a/2019b/2024b 2.附赠案例数据可直接运行。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。


