473,657 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Confused about Response.Status Code

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 sendToXMLGateWa y()
{
string valueToReturn = "";
string lcUrl = "http://mywebsite.com/vbprogram.aspx" ;
HttpWebRequest webreq = (HttpWebRequest ) WebRequest.Crea te
(lcUrl);

HttpWebResponse loWebResponse = (HttpWebRespons e)
webreq.GetRespo nse();
valueToReturn = loWebResponse.S tatusCode.ToStr ing();
loWebResponse.C lose();
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.EventArg s) Handles MyBase.Load
Response.Status Code = "200"
End Sub

Nov 18 '05 #1
1 1500
Shane,

Response.Status Code 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.Status Code 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*******@disc ussions.microso ft.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 sendToXMLGateWa y()
{
string valueToReturn = "";
string lcUrl = "http://mywebsite.com/vbprogram.aspx" ;
HttpWebRequest webreq = (HttpWebRequest ) WebRequest.Crea te
(lcUrl);

HttpWebResponse loWebResponse = (HttpWebRespons e)
webreq.GetRespo nse();
valueToReturn = loWebResponse.S tatusCode.ToStr ing();
loWebResponse.C lose();
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.EventArg s) Handles MyBase.Load
Response.Status Code = "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
9380
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 comes back as part of the response and obviously causes the xmlDoc.Load(myResponseStream) to break because the test preceding the XML makes the xml invalid. How can I remove this content from the receiving XML stream ?? Here is some sample code :
4
30289
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 strResponse; // Create the request obj
0
2849
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 the HttpWebResponse or HttpResponse to get the status code back but it doesn't seem to work. Is the Response.StatusCode assignment below only visiable to the web application below or is this the response that is sent back to any programs that...
0
1075
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 set to 304 when necessary always shows up in the server log as a 200 even when the 304 is issued. The browser doesn't error and behaves as expected, but I want to be able to log the 304s as 304s, not 200s with a VERY small contentlength. ...
4
3330
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 database of validated users to determine whether the particular user can actually use the system. If a user is not in the database, I want to respond with the same error page as would be seen if they failed the windows authentication; the 403...
4
10882
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 text files. I searched the Internet and found a basic example which I changed to fit my needs. I tested it out first on a single URL and it worked fine. Now when I incorporate an array of URL's, it fails to work. The first "responseFromServer"...
1
3834
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 = (int)HttpStatusCode.ServiceUnavailable; I am lead to believe that there is the ability to specify the "retry-after" parameter in the header, but I am unsure how to do it in ..Net2
2
1275
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 ther server and I want to do it in the HTTP Headers. The status code is "204" for no content.
10
14229
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 customer exist in my database and if exist show page (http StatusCode == 200), but if customer with number 1395 not exist I need make 404 http error (page not exist) I am tring to do something like protected void Page_Load(object sender,...
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5642
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
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 we have to send another system
2
1970
muto222
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.