473,473 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

constants for http status codes

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
6 2531
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Raymond Hettinger | last post by:
Comments are invited on the following proposed PEP. Raymond Hettinger ------------------------------------------------------- PEP: 329
9
by: Gianni Mariani | last post by:
I'm involved in a new project and a new member on the team has voiced a strong opinion that we should utilize exceptions. The other members on the team indicate that they have either been burned...
1
by: chris fink | last post by:
Hi, What are the appropriate HTTP Status Codes for the following: 1. XML is not well-formed (structure problem).... 2. XML is not valid (as per DTD/XSD/XDR).....missing req'd field, etc I...
2
by: bwmiller16 | last post by:
Anyone - Can anybody tell me where I would find the linux status codes for such udb utilities as backup, etc.? For instance, in my cron job I have: db2 backup database $dir to $BACKUP_DIR...
1
by: maria obrien | last post by:
FYI Mr/Ms McDermott. sorry if i'm giving too much info and thank you for replying to my query. hope this will make my problem clearer. The term_cont table contains the contact records (with...
1
by: centrino | last post by:
Hi all, I'm trying to access the extended Passthru from http://www.wd-3.com/031504/PTEx3_index.htm using C#. Anybody know how to get the correct iocontrol codes of : ...
0
by: Daniel Kopp | last post by:
Hi! I tried to implement custom error pages using the <customErrors> directive in a web.config file. It worked fine for "simple" errors like HTTP 404, like this example: <customErrors...
1
by: chen | last post by:
We're having an internal debate about the merits & demerits of returning status codes in the output message vs exceptions to signify errors in handling a Web method. The status code camp is...
2
by: Bob | last post by:
I'm running sql server ver 7.0 SP4. I have an access project (.adp) that runs a view which is nothing more than a select statement. Access locks up solid when I try to run this query - with NO...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.