473,395 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Confused about Response.StatusCode

I want the function in Code Snippet #1 below to return a
string of "200" by making a web request for
the vbprogram.aspx that contains the PageLoad function in
Code Snippet #2 below. Instead, I am getting a StatusCode
of "OK" instead of 200. What should I change here? Thanks
in advance for any help anyone may be able to give.
Code Snippet #1 (The function that does the web request.)
(from a C# program I wrote.)

public string sendToXMLGateWay()
{
string valueToReturn = "";
string lcUrl = "http://mywebsite.com/vbprogram.aspx";
HttpWebRequest webreq = (HttpWebRequest) WebRequest.Create
(lcUrl);

HttpWebResponse loWebResponse = (HttpWebResponse)
webreq.GetResponse();
valueToReturn = loWebResponse.StatusCode.ToString();
loWebResponse.Close();
return (valueToReturn);
}

Code Snippet #2 (From the vbprogram that should reply with
Status Code of 200.)
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
Response.StatusCode = "200"
End Sub

Nov 18 '05 #1
1 1486
Shane,

Response.StatusCode is of type Integer, so you could just try using
CType(Response.StatusCode, String) to see if that works.

I've not had a chance to look it up, but it could be that the .ToString
method of Response.StatusCode transforms the numeric StatusCode into the
text equivalent - so if the code were 404, it would respond with "File Not
Found".

Hopefully this method will work.

Regards,
Anthony
"Shane" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
I want the function in Code Snippet #1 below to return a
string of "200" by making a web request for
the vbprogram.aspx that contains the PageLoad function in
Code Snippet #2 below. Instead, I am getting a StatusCode
of "OK" instead of 200. What should I change here? Thanks
in advance for any help anyone may be able to give.
Code Snippet #1 (The function that does the web request.)
(from a C# program I wrote.)

public string sendToXMLGateWay()
{
string valueToReturn = "";
string lcUrl = "http://mywebsite.com/vbprogram.aspx";
HttpWebRequest webreq = (HttpWebRequest) WebRequest.Create
(lcUrl);

HttpWebResponse loWebResponse = (HttpWebResponse)
webreq.GetResponse();
valueToReturn = loWebResponse.StatusCode.ToString();
loWebResponse.Close();
return (valueToReturn);
}

Code Snippet #2 (From the vbprogram that should reply with
Status Code of 200.)
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
Response.StatusCode = "200"
End Sub

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Vivek Mehta | last post by:
I want to receive XML stream generated at another URL however when I try to load the XML it errors out with one error or the other. I beleive this XML comes back with HTTP header which actually...
4
by: Chris Fink | last post by:
How do I retrieve the HTTP Status code (ie 202, 404, etc) below? I am currently receiving the response text but unable to access the response status code. string strNewValue; string...
0
by: Shane | last post by:
Can someone tell me what the Response.StatusCode = "200" is doing below? I have another program that sends a stream of string data to the program below by using an HttpWebRequest. I want to use...
0
by: Adrian Inman | last post by:
I have some image resizing code that resizes images and composites them with watermarks on the fly. I have integrated HTTP eTag aware caching with the code, however, the Response.StatusCode which I...
4
by: Martin Robins | last post by:
I have an application which uses Windows Authentication to identify users and ensure that they are on a domain. Once access is granted at this level, I then check their login name against a...
4
by: Hexman | last post by:
Code below ---- I've asked a similar question on this forum earlier. This is a slightly different situation. Previous Question ---- I'm trying to save some specific web pages to disk as...
1
by: Flip Rayner | last post by:
I am writing an HTTPHandler that is basically a transparent proxy / URL Mapper. I have a line in my code to return a 503: context.context.Response.StatusCode = ...
2
by: pbd22 | last post by:
Hi. I feel like i should know this but i dont. How do I get the server to send a specific HTTP response to the browser? I want to tell the browser that there is no content coming back from...
10
by: =?Utf-8?B?U3VzaGlTZWFu?= | last post by:
Hello. I need use http header StatusCode as response. For example my page have name check.aspx and I get request like this check.aspx?idcustomer=1395 I use this idcustomer param to check if this...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.