Alex, thanks again, works like a charm
:)
"Alex Passos" <bz@netmerlin.nospam.com> wrote in message
news:evLlXUUOFHA.3336@TK2MSFTNGP09.phx.gbl...[color=blue]
> I have actually not tried this but I wonder if you can cast the StatusCode
> to an integer (or convert via System.Convert). The MSDN docs mention that
> each status code maps to a numerical representation of the code:
>
>[/color]
http://msdn.microsoft.com/library/de...classtopic.asp[color=blue]
>
> Alex
>
> "Chris Fink" <chris.fink@gmail.com> wrote in message
> news:%23awGIGUOFHA.4028@tk2msftngp13.phx.gbl...[color=green]
> > This works great, thank you. However, I would like to return the actual
> > status code instead of the public enum HttpStatusCode representation.[/color][/color]
For[color=blue][color=green]
> > example, I would to see 202 instead of Accepted.
> >
> > Is this possible?
> >
> > "Alex Passos" <bz@netmerlin.nospam.com> wrote in message
> > news:uTYnVMTOFHA.3336@TK2MSFTNGP09.phx.gbl...[color=darkred]
> >> Hi Chris,
> >>
> >> HttpWebResponse rep = req.GetResponse();
> >> HttpStatusCode c = rep.StatusCode;
> >>
> >> when getting the response you may have to deal with exceptions if the
> >> request is not successful so wrap it in a try-catch block.
> >>
> >> Alex
> >>
> >> "Chris Fink" <chris.fink@gmail.com> wrote in message
> >> news:eXs2QCTOFHA.3960@TK2MSFTNGP12.phx.gbl...
> >> > How do I retrieve the HTTP Status code (ie 202, 404, etc) below? I[/color][/color][/color]
am[color=blue][color=green][color=darkred]
> >> > currently receiving the response text but unable to access the[/color][/color][/color]
response[color=blue][color=green][color=darkred]
> >> > status code.
> >> >
> >> >
> >> > string strNewValue;
> >> >
> >> > string strResponse;
> >> >
> >> > // Create the request obj
> >> >
> >> > HttpWebRequest req = (HttpWebRequest) WebRequest.Create(txtURL.Text);
> >> >
> >> > // Set values for the request back
> >> >
> >> > req.Method = "POST";
> >> >
> >> > //req.ContentType = "application/x-www-form-urlencoded";
> >> >
> >> > strNewValue = Server.HtmlDecode(txtRequest.Value.ToString());
> >> >
> >> > //req.ContentLength = strNewValue.Length;
> >> >
> >> > req.
> >> >
> >> > // Write the request
> >> >
> >> > StreamWriter stOut = new StreamWriter (req.GetRequestStream(),
> >> > System.Text.Encoding.ASCII);
> >> >
> >> > stOut.Write(strNewValue);
> >> >
> >> > stOut.Close();
> >> >
> >> > // Do the request to get the response
> >> >
> >> > StreamReader stIn = new
> >> > StreamReader(req.GetResponse().GetResponseStream() );
> >> >
> >> > strResponse = stIn.ReadToEnd();
> >> >
> >> > stIn.Close();
> >> >
> >> > txtResponse.Value = strResponse;
> >> >
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]