Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSXML2.ServerXMLHTTP object always returning status 200

Status
Not open for further replies.

mit99mh

Programmer
Sep 24, 2002
246
GB
I've got to check urls to ensure they are real before inserting into a db I'm using the MSXML2.ServerXMLHTTP object, it works when the server address (eg abc.intra.abc.com) is correct but incorrectly returns a 200 status code even when a missing file is appended to the server name (abc.intra.abc.com/missing.asp) the url should result in a 404 - any ideas?
CODE:

on Error resume next

strTestUrl = "
Set objHttpRequest = CreateObject("MSXML2.ServerXMLHTTP")
objHttpRequest.Open "GET", strTestUrl
objHttpRequest.Send

if(Err.Number <> 0)then
Response.Write &quot;url problem&quot;
else
Response.Write objHttpRequest.Status
end if

Select Case objHttpRequest.Status
Case 200 'No problem!
Response.Write strTestUrl & &quot; is a valid, available URL&quot;
Case 404 'Not found
Response.Write strTestUrl & &quot; could not be found (404 Error)&quot;

Case Else 'Some other problem
Response.Write &quot;An unexpected HTTP Status value was returned: &quot; & .Status
End Select
Set objHttpRequest = Nothing


Any help much appreciated
 
Hmm, I tried your code on my local machine and gave it a non-existant address locally that it returned a 404 for. I don't see the issue (except for the semi-colong after setting the strTestURL).

-Tarwn

01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Do you know how hot your computer is running at home? I do
 
Thanks for replying - but typo aside i only ever get a 200 code returned.

Thanks anyway..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top