constants for http status codes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Fish

    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
    HttpServletResp onse.SC_NOT_FOU ND for 404 etc.

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

    Andy


  • John Timney \(ASP.NET MVP\)

    #2
    Re: constants for http status codes

    The httpWebResponse object has a statusCode property

    --
    Regards

    John Timney
    ASP.NET MVP
    Microsoft Regional Director

    "Andy Fish" <ajfish@blueyon der.co.uk> wrote in message
    news:OLIT02$HFH A.3336@TK2MSFTN GP10.phx.gbl...[color=blue]
    > 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
    > HttpServletResp onse.SC_NOT_FOU ND for 404 etc.
    >
    > All the examples I've seen just use numbers. Anyone seen proper constant
    > definitions for these?
    >
    > Andy
    >
    >[/color]


    Comment

    • Scott Allen

      #3
      Re: constants for http status codes

      Hi Andy:

      Are you looking for System.Net.Http StatusCode ?

      --
      Scott


      On Thu, 3 Mar 2005 14:31:29 -0000, "Andy Fish"
      <ajfish@blueyon der.co.uk> wrote:
      [color=blue]
      >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
      >HttpServletRes ponse.SC_NOT_FO UND for 404 etc.
      >
      >All the examples I've seen just use numbers. Anyone seen proper constant
      >definitions for these?
      >
      >Andy
      >[/color]

      Comment

      • Andy Fish

        #4
        Re: constants for http status codes

        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.G etHttpCode() return an int instead.

        Still, by casting the HttpStatusCode to an int, I achieved the desired
        result.


        "Scott Allen" <scott@nospam.o detocode.com> wrote in message
        news:7s9e21l917 jssse87psd4pqk2 cvpg2qj9l@4ax.c om...[color=blue]
        > Hi Andy:
        >
        > Are you looking for System.Net.Http StatusCode ?
        >
        > --
        > Scott
        > http://www.OdeToCode.com/blogs/scott/
        >
        > On Thu, 3 Mar 2005 14:31:29 -0000, "Andy Fish"
        > <ajfish@blueyon der.co.uk> wrote:
        >[color=green]
        >>Hi,
        >>
        >>I've RTFM'd in vain for some named constants in the asp.net framework
        >>representin g the HTTP error codes - the equivalent of Java's
        >>HttpServletRe sponse.SC_NOT_F OUND for 404 etc.
        >>
        >>All the examples I've seen just use numbers. Anyone seen proper constant
        >>definitions for these?
        >>
        >>Andy
        >>[/color]
        >[/color]


        Comment

        • Juan T. Llibre

          #5
          Re: constants for http status codes

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



          "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.Http Response.Status Code 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

          Foros de ASP.NET en Español
          Ven, y hablemos de ASP.NET...
          =============== =======

          "Andy Fish" <ajfish@blueyon der.co.uk> wrote in message
          news:OLIT02$HFH A.3336@TK2MSFTN GP10.phx.gbl...[color=blue]
          > 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
          > HttpServletResp onse.SC_NOT_FOU ND for 404 etc.
          >
          > All the examples I've seen just use numbers. Anyone seen proper constant
          > definitions for these?
          >
          > Andy
          >
          >[/color]


          Comment

          • Andy Fish

            #6
            Re: constants for http status codes

            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" <nomailreplies@ nowhere.com> wrote in message
            news:%23IW$UnAI FHA.2420@TK2MSF TNGP14.phx.gbl. ..[color=blue]
            > 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.Http Response.Status Code 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" <ajfish@blueyon der.co.uk> wrote in message
            > news:OLIT02$HFH A.3336@TK2MSFTN GP10.phx.gbl...[color=green]
            >> 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
            >> HttpServletResp onse.SC_NOT_FOU ND for 404 etc.
            >>
            >> All the examples I've seen just use numbers. Anyone seen proper constant
            >> definitions for these?
            >>
            >> Andy
            >>
            >>[/color]
            >
            >[/color]


            Comment

            • Juan T. Llibre

              #7
              Re: constants for http status codes

              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

              Foros de ASP.NET en Español
              Ven, y hablemos de ASP.NET...
              =============== =======

              "Andy Fish" <ajfish@blueyon der.co.uk> wrote in message
              news:ui$HGiJIFH A.2564@tk2msftn gp13.phx.gbl...[color=blue]
              > 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" <nomailreplies@ nowhere.com> wrote in message
              > news:%23IW$UnAI FHA.2420@TK2MSF TNGP14.phx.gbl. ..[color=green]
              >> 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.Http Response.Status Code 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" <ajfish@blueyon der.co.uk> wrote in message
              >> news:OLIT02$HFH A.3336@TK2MSFTN GP10.phx.gbl...[color=darkred]
              >>> 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
              >>> HttpServletResp onse.SC_NOT_FOU ND for 404 etc.
              >>>
              >>> All the examples I've seen just use numbers. Anyone seen proper constant
              >>> definitions for these?
              >>>
              >>> Andy
              >>>
              >>>[/color]
              >>
              >>[/color]
              >
              >[/color]


              Comment

              Working...