B
Brett
I'm having difficults getting at values of an object. Here is my code,
which only gets a webpage. The two values I can't reach have comments next
to them. I've also listed the watches tree and with values I'd like to get
within the wResp object.
Dim wReq As WebRequest = WebRequest.Create(url)
If TypeOf wReq Is HttpWebRequest Then
CType(wReq, HttpWebRequest).UserAgent = "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1; Feedreader; .NET CLR 1.1.4322; .NET
CLR 2.0.40607)"
End If
Dim wResp As WebResponse = wReq.GetResponse()
myContentType = wResp.ContentType
myStatusCode= wResp.StatusCode 'this is not valid
myStatusDescription = wResp.StatusDescription 'this is not
valid
In the Watches window, the tree for wResp looks like this:
Name Value
Type
- wResp
{System.Net.HttpWebResponse} System.Net.HttpWebResponse
- {System.Net.HttpWebResponse} {System.Net.HttpWebResponse}
System.Net.HttpWebResponse
ContentType "image/gif"
String
StatusCode OK
System.Net.HttpStatusCode
StatusDescription "OK"
String
I don't see a wResp.StatusCode or wResp.StatusDescription listed in the drop
down pop hint. What am I missing to get at those values?
Also, how do I get the numerical values of response codes? Such as "OK" =
200 or "Bad request" = 400. I don't see anything like that listed in the
watch window.
Thanks,
Brett
which only gets a webpage. The two values I can't reach have comments next
to them. I've also listed the watches tree and with values I'd like to get
within the wResp object.
Dim wReq As WebRequest = WebRequest.Create(url)
If TypeOf wReq Is HttpWebRequest Then
CType(wReq, HttpWebRequest).UserAgent = "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1; Feedreader; .NET CLR 1.1.4322; .NET
CLR 2.0.40607)"
End If
Dim wResp As WebResponse = wReq.GetResponse()
myContentType = wResp.ContentType
myStatusCode= wResp.StatusCode 'this is not valid
myStatusDescription = wResp.StatusDescription 'this is not
valid
In the Watches window, the tree for wResp looks like this:
Name Value
Type
- wResp
{System.Net.HttpWebResponse} System.Net.HttpWebResponse
- {System.Net.HttpWebResponse} {System.Net.HttpWebResponse}
System.Net.HttpWebResponse
ContentType "image/gif"
String
StatusCode OK
System.Net.HttpStatusCode
StatusDescription "OK"
String
I don't see a wResp.StatusCode or wResp.StatusDescription listed in the drop
down pop hint. What am I missing to get at those values?
Also, how do I get the numerical values of response codes? Such as "OK" =
200 or "Bad request" = 400. I don't see anything like that listed in the
watch window.
Thanks,
Brett