Ford-p
Active member
- Joined
- Mar 1, 2007
- Messages
- 30
- Programming Experience
- Beginner
Hey,
I'm trying to get the HttpWebResponse StatusCode (e.g. 404) of a website. I have the following code that works:
This works for any response apart from 404, because my ISP (Tiscali UK) redirect 404 pages to there search page. Is there any way to get the response from the real site or am I stuck with the ISP redirection?
Hope that makes sense,
Joe
I'm trying to get the HttpWebResponse StatusCode (e.g. 404) of a website. I have the following code that works:
VB.NET:
Private Function GetResponse(ByRef uriURL As Uri, Optional ByVal strUsername As String = "", Optional ByVal strPassword As String = "") As HttpWebResponse
Dim objRequest As HttpWebRequest = CType(HttpWebRequest.Create(uriURL), HttpWebRequest)
objRequest.Credentials = New NetworkCredential(strUsername, strPassword)
Try
Return CType(objRequest.GetResponse(), HttpWebResponse)
Catch ex As WebException
If ex.Status = WebExceptionStatus.ProtocolError Then
Return CType(ex.Response, HttpWebResponse)
End If
End Try
Return Nothing
End Function
This works for any response apart from 404, because my ISP (Tiscali UK) redirect 404 pages to there search page. Is there any way to get the response from the real site or am I stuck with the ISP redirection?
Hope that makes sense,
Joe