By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,905 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,905 IT Pros & Developers. It's quick & easy.

constants for http status codes

P: n/a
Hi,

I've RTFM'd in vain for some named constants in the asp.net framework
representing the HTTP error codes - the equivalent of Java's
HttpServletResponse.SC_NOT_FOUND for 404 etc.

All the examples I've seen just use numbers. Anyone seen proper constant
definitions for these?

Andy
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
The httpWebResponse object has a statusCode property

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
Hi,

I've RTFM'd in vain for some named constants in the asp.net framework
representing the HTTP error codes - the equivalent of Java's
HttpServletResponse.SC_NOT_FOUND for 404 etc.

All the examples I've seen just use numbers. Anyone seen proper constant
definitions for these?

Andy

Nov 19 '05 #2

P: n/a
Hi Andy:

Are you looking for System.Net.HttpStatusCode ?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 3 Mar 2005 14:31:29 -0000, "Andy Fish"
<aj****@blueyonder.co.uk> wrote:
Hi,

I've RTFM'd in vain for some named constants in the asp.net framework
representing the HTTP error codes - the equivalent of Java's
HttpServletResponse.SC_NOT_FOUND for 404 etc.

All the examples I've seen just use numbers. Anyone seen proper constant
definitions for these?

Andy


Nov 19 '05 #3

P: n/a
Thanks, that's (almost) what I was looking for.

It seems a bit strange to go to all the trouble of defining an enum and then
have HttpException.GetHttpCode() return an int instead.

Still, by casting the HttpStatusCode to an int, I achieved the desired
result.
"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:7s********************************@4ax.com...
Hi Andy:

Are you looking for System.Net.HttpStatusCode ?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 3 Mar 2005 14:31:29 -0000, "Andy Fish"
<aj****@blueyonder.co.uk> wrote:
Hi,

I've RTFM'd in vain for some named constants in the asp.net framework
representing the HTTP error codes - the equivalent of Java's
HttpServletResponse.SC_NOT_FOUND for 404 etc.

All the examples I've seen just use numbers. Anyone seen proper constant
definitions for these?

Andy

Nov 19 '05 #4

P: n/a
The Reason-Phrase constants are not needed for
programming puprposes, according to rfc2616 :

http://www.rfc-editor.org/rfc/rfc2616.txt

"The Reason-Phrase is intended to give a short textual
description of the Status-Code. The Status-Code is
intended for use by automata and the Reason-Phrase
is intended for the human user."

The System.web.HttpResponse.StatusCode method
allows you to program against the Status Code numbers.

Search that document for "The first digit of the Status-Code"
to see a complete description for each Status Code
and their Reason-Phrases.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
Hi,

I've RTFM'd in vain for some named constants in the asp.net framework
representing the HTTP error codes - the equivalent of Java's
HttpServletResponse.SC_NOT_FOUND for 404 etc.

All the examples I've seen just use numbers. Anyone seen proper constant
definitions for these?

Andy

Nov 19 '05 #5

P: n/a
Agreed, but I wasn't talking about processing the reason phrase. I was
talking about having a named constant used to represent to the integer
status code value, rather than putting the number 404 in my code all over
the place.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
The Reason-Phrase constants are not needed for
programming puprposes, according to rfc2616 :

http://www.rfc-editor.org/rfc/rfc2616.txt

"The Reason-Phrase is intended to give a short textual
description of the Status-Code. The Status-Code is
intended for use by automata and the Reason-Phrase
is intended for the human user."

The System.web.HttpResponse.StatusCode method
allows you to program against the Status Code numbers.

Search that document for "The first digit of the Status-Code"
to see a complete description for each Status Code
and their Reason-Phrases.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
Hi,

I've RTFM'd in vain for some named constants in the asp.net framework
representing the HTTP error codes - the equivalent of Java's
HttpServletResponse.SC_NOT_FOUND for 404 etc.

All the examples I've seen just use numbers. Anyone seen proper constant
definitions for these?

Andy


Nov 19 '05 #6

P: n/a
Hi, Andy.

Thanks for clarifying.

I suppose that the reason for using integer status code values,
as opposed to using named constants, would have to do with
terseness of code ( less verbosity ).

SC_NOT_FOUND is much more verbose than 404.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:ui**************@tk2msftngp13.phx.gbl...
Agreed, but I wasn't talking about processing the reason phrase. I was
talking about having a named constant used to represent to the integer
status code value, rather than putting the number 404 in my code all over
the place.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
The Reason-Phrase constants are not needed for
programming puprposes, according to rfc2616 :

http://www.rfc-editor.org/rfc/rfc2616.txt

"The Reason-Phrase is intended to give a short textual
description of the Status-Code. The Status-Code is
intended for use by automata and the Reason-Phrase
is intended for the human user."

The System.web.HttpResponse.StatusCode method
allows you to program against the Status Code numbers.

Search that document for "The first digit of the Status-Code"
to see a complete description for each Status Code
and their Reason-Phrases.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
Hi,

I've RTFM'd in vain for some named constants in the asp.net framework
representing the HTTP error codes - the equivalent of Java's
HttpServletResponse.SC_NOT_FOUND for 404 etc.

All the examples I've seen just use numbers. Anyone seen proper constant
definitions for these?

Andy



Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.