HTTP状态码数量有问题 [英] problem in number HTTP status codes

查看:89
本文介绍了HTTP状态码数量有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


为http获取一个 HTTP状态代码列表的编号.我用HttpWebResponse


get http a number List of HTTP status codes . what i get that number with HttpWebResponse

推荐答案

得到的号码是什么?您尝试查看 ^ ]?
Did you try looking at the documentation[^]?


我认为您快到了.

您必须使用HttpWebResponse.StatusCode,其值将为OK,Accepted,Redirect等.这是一个枚举,如果您需要数字值,则只需将其强制转换为以下形式:
I think you are almost there.

You have to use HttpWebResponse.StatusCode, which will have a value of OK, Accepted, Redirect, etc. This is an enum and if you need the numerical value, all you have to do is cast it like this:
int code = (int)HttpWebResponse.StatusCode;



如果HttpWebResponse.StatusCode == OK,则代码==200.

Soren Madsen



If HttpWebResponse.StatusCode == OK, then code == 200.

Soren Madsen


您遇到的问题是,与解决方案体系结构相比,HTTP在解决方案体系结构中的层次更低.

超文本传输​​协议-关键字是传输.传输从客户端Internet浏览器开始,并在ASP.Net应用程序中结束.

ASP.Net只知道从客户端到Internet,到托管网络,到Web服务器,再到Web服务器再到ASP.Net引擎的所有请求.

HTTP-500内部服务器错误

这通常是由IIS配置错误引起的.如果IIS配置不当,则无法将请求从客户端发送到ASP.Net引擎.在这种情况下,请求生命周期将不会开始,相关模块和处理程序将不会执行,并且包括HttpWebResponse对象在内的ASP.Net应用程序将变得完全无知.
在IIS中,可以启用失败的请求跟踪".这将报告IIS返回的任何错误状态代码,即使它们没有发送到ASP.Net引擎也是如此.

http://learn .iis.net/page.aspx/488/using-failed-request-tracing-rules-to-troubleshoot-application-request-routing-arr/ [ http://blogs.msdn.com/b/rakkimk/archive/2007/03/01/writing-a-simple-isapi-filter.aspx [
The problem you''ve got is HTTP is at a lower level within the solution architecture than ASP.Net.

Hyper Text Transport Protocol - The key word is transport. The transport begins within the client internet browser and ends in your ASP.Net application.

ASP.Net is only aware of requests which make it all the way from the client, across the internet, into you hosting network, to your web server and then from your web server to the ASP.Net engine.

HTTP - 500 Internal Server Error

This is often caused by a bad configuration of IIS. If IIS is poorly configured then there''s no way the request is going to get from the client to the ASP.Net engine. In which case the request life cycle won''t begin, the relevant modules and handlers won''t execute and your ASP.Net application including it HttpWebResponse object are going to be completely ignorant.

In IIS you can enable Failed Request Tracing. This will report any bad status codes returned by IIS even if they don''t make it to the ASP.Net engine.

http://learn.iis.net/page.aspx/488/using-failed-request-tracing-rules-to-troubleshoot-application-request-routing-arr/[^]

Once you''ve developed an understanding of the structure of this log you could write code to automatically read the log and report bad statuses in a more convenient way.

IIS also supports a technology called ISAPI (Internet Server Application Programming Interface). ISAPI layers are lower in the solution architecture than the ASP.Net engine.

The following outlines how to write a simple ISAPI layer. It is possible that adding your own ISAPI layer would allow you to capture HTTP status codes which would be missed by the ASP.Net engine but this is not a catch all.

http://blogs.msdn.com/b/rakkimk/archive/2007/03/01/writing-a-simple-isapi-filter.aspx[^]

There are HTTP status codes for timeouts. If the timeout is caused by the clients local ISP then there''s no way you''re ever going to know about the request or the returned status code.

In a nutshell. You will never get all of the valid statuses listed for a HTTP request/response within the ASP.Net engine as HTTP covers area''s well beyond the scope of responsibility of ASP.Net.

For this very reason, the enumerator doesn''t need to contain all the HTTP status codes.


这篇关于HTTP状态码数量有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆