PC Review


Reply
Thread Tools Rate Thread

404 error with WebClient request

 
 
Tony B
Guest
Posts: n/a
 
      27th Nov 2003
Hi,
When I make a request for a web page using the System.Net.WebClient class
I'm getting a page not found (404) error for a webpage that I know exists.

Here's the relevent bit of code:

aRequestedHTML = objWebClient.DownloadData(strUrl)
strRequestedHTML = objUTF8.GetString(aRequestedHTML)

aRequestedHTML is a byte array, strUrl is a full url such as
http://10.0.1.6/categories/index.asp and strRequestedHTML is the output of
the request.

The exception I get is:

WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at Neop.Module1.ReadWebPage(String strUrl)

The webserver is on the same machine the application runs on. I know the url
exists as I can see it in a browser. Also if I run the application from a
different machine I don't get any errors and the HTML for the page is
returned.

Anyone got any ideas?

Tony


 
Reply With Quote
 
 
 
 
Cor
Guest
Posts: n/a
 
      27th Nov 2003
Hi Tony,

Mostly a sucurity isue but which one I would not know, try the newsgroup
framework security and adonet also, probably there you have a better change.

Although I would try it if it is a local computer with 127.0.0.1 or
localhost also.


Cor

> I'm getting a page not found (404) error for a webpage that I know exists.
> Here's the relevent bit of code:
> aRequestedHTML = objWebClient.DownloadData(strUrl)
> strRequestedHTML = objUTF8.GetString(aRequestedHTML)
> aRequestedHTML is a byte array, strUrl is a full url such as
> http://10.0.1.6/categories/index.asp and strRequestedHTML is the output >

the request.
>
> The exception I get is:
>
> WebException: The remote server returned an error: (404) Not Found.
> at System.Net.HttpWebRequest.CheckFinalStatus()
> at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
> at System.Net.HttpWebRequest.GetResponse()
> at Neop.Module1.ReadWebPage(String strUrl)
>
> The webserver is on the same machine the application runs on. I know the

url
> exists as I can see it in a browser. Also if I run the application from a
> different machine I don't get any errors and the HTML for the page is
> returned.
>



 
Reply With Quote
 
 
 
 
Tony B
Guest
Posts: n/a
 
      27th Nov 2003
I think I've solved my own problem, I'm posting the solution here in case
anyone searching at Google Groups later has encountered the same problem.

It seems that the WebClient class doesn't work as expected if it's requests
go to a
local web server with a request to an IP address. I've added the IP address
to my local hosts file with a host name. I changed my application so that it
used the host name in place of the IP address and everything worked.

Tony




 
Reply With Quote
 
One Handed Man
Guest
Posts: n/a
 
      27th Nov 2003
Tony,
Just a guess but could this be a DNS issue. What if you replace
the IP address with the 127.0.0.0, does this make any difference when
calling it programitically.

Alternatively, try putting an entry for your machine in the hosts file and
calling the URL by name rather than by IP address to see if this helps.

Regards - OHM


Tony B wrote:
> Hi,
> When I make a request for a web page using the System.Net.WebClient
> class I'm getting a page not found (404) error for a webpage that I
> know exists.
>
> Here's the relevent bit of code:
>
> aRequestedHTML = objWebClient.DownloadData(strUrl)
> strRequestedHTML = objUTF8.GetString(aRequestedHTML)
>
> aRequestedHTML is a byte array, strUrl is a full url such as
> http://10.0.1.6/categories/index.asp and strRequestedHTML is the
> output of the request.
>
> The exception I get is:
>
> WebException: The remote server returned an error: (404) Not Found.
> at System.Net.HttpWebRequest.CheckFinalStatus()
> at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
> at System.Net.HttpWebRequest.GetResponse()
> at Neop.Module1.ReadWebPage(String strUrl)
>
> The webserver is on the same machine the application runs on. I know
> the url exists as I can see it in a browser. Also if I run the
> application from a different machine I don't get any errors and the
> HTML for the page is returned.
>
> Anyone got any ideas?
>
> Tony



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      27th Nov 2003
Three in a row, but almost the same thought and so fast we cannot type and
send that we did see it from each other

:-))


 
Reply With Quote
 
One Handed Man
Guest
Posts: n/a
 
      27th Nov 2003
Tony,
It looks as if I was heading in the right direction then as you
see I suggested this in my reply to you before you posted this one.

Regards - OHM


Tony B wrote:
> I think I've solved my own problem, I'm posting the solution here in
> case anyone searching at Google Groups later has encountered the same
> problem.
>
> It seems that the WebClient class doesn't work as expected if it's
> requests go to a
> local web server with a request to an IP address. I've added the IP
> address to my local hosts file with a host name. I changed my
> application so that it used the host name in place of the IP address
> and everything worked.
>
> Tony



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      27th Nov 2003
* "Cor" <(E-Mail Removed)> scripsit:
> framework security and adonet also, probably there you have a better change.


Just FMI: ADO.NET or ASP.NET?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Tony B
Guest
Posts: n/a
 
      27th Nov 2003

"One Handed Man" <(E-Mail Removed)> wrote in message
news:bq52kg$n37$(E-Mail Removed)...
> Tony,
> It looks as if I was heading in the right direction then as

you
> see I suggested this in my reply to you before you posted this one.
>
> Regards - OHM
>


Looks like great minds think alike!

My second post appeared at the same time as your first one! Same time stamp
in my newsreader.

Thanks for your input.

Tony


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      27th Nov 2003
Asp.net you are right mistake of me while typing

:-))


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      27th Nov 2003
Hi Herfried,

I did not see comments on that Beer message/answer from me, where I wrote
that for you would be better Villacher or Urquel, what is it in Wien?

Cor

PS for me is Urquel from fust in the Pilsen area the best beer I know (not
in a bottle).


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If you drag a meeting request or task request from your Inbox toCalendar or Tasks, the request is automatically accepted and an acceptancereply is sent to the senders. 34345445 Microsoft Access 0 3rd Mar 2006 02:09 AM
Intercept IIS 404 errors? Issue with Viewstate and 404 Jonathan Folland Microsoft ASP .NET 2 17th Mar 2005 03:32 AM
Can you intercept the url request before a 404 error occurs? =?Utf-8?B?UlVTU0VMTCBNQ0dJTk5JUw==?= Microsoft ASP .NET 1 14th Jul 2004 03:45 PM
WebClient DownloadFile gets ALL files in directory?!? WebClient bug? Jeremy Microsoft Dot NET Framework 1 10th Nov 2003 02:10 PM
Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How??? Brian Birtle Microsoft ASP .NET 2 16th Oct 2003 03:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:06 AM.