Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > HttpWebRequest.GetResponse returns 404 No Found error

Reply
Thread Tools

HttpWebRequest.GetResponse returns 404 No Found error

 
 
warlord
Guest
Posts: n/a
 
      04-01-2004
I have a windows client app that is trying to download a file from
a web server but I always get the following error when I call the
GetResponse method of the Request object.

The remote server returned an error: (404) Not Found.

When I run it against a website on my local machine everything works
perfectly, but not against the remote server. I'm sure it's a security
or permissions problem of some sort, but I'm not sure where to start.

The code I'm using is below.

Thanks in advance for any help.

Cameron


HttpWebResponse Response;

//Retrieve the File
HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
Request.Headers.Add("Translate: f");
Request.Credentials = CredentialCache.DefaultCredentials;

try
{
Response = (HttpWebResponse)Request.GetResponse();
}
catch(WebException e)
{
//Handle the exception here
}
finally
{
Response.Close()
}


 
Reply With Quote
 
 
 
 
Ken Schaefer
Guest
Posts: n/a
 
      04-01-2004
Is the remote server an IIS 6.0 box? If so, is WebDAV enabled?
Does the URL requested actually exist?

Cheers
Ken

"warlord" <> wrote in message
news:...
: I have a windows client app that is trying to download a file from
: a web server but I always get the following error when I call the
: GetResponse method of the Request object.
:
: The remote server returned an error: (404) Not Found.
:
: When I run it against a website on my local machine everything works
: perfectly, but not against the remote server. I'm sure it's a security
: or permissions problem of some sort, but I'm not sure where to start.
:
: The code I'm using is below.
:
: Thanks in advance for any help.
:
: Cameron
:
:
: HttpWebResponse Response;
:
: //Retrieve the File
: HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
: Request.Headers.Add("Translate: f");
: Request.Credentials = CredentialCache.DefaultCredentials;
:
: try
: {
: Response = (HttpWebResponse)Request.GetResponse();
: }
: catch(WebException e)
: {
: //Handle the exception here
: }
: finally
: {
: Response.Close()
: }
:
:


 
Reply With Quote
 
 
 
 
warlord
Guest
Posts: n/a
 
      04-01-2004
The web server is IIS 5.0, and the Url does exist. I can get to it via a
browser without any problems - it's just from within the windows app that it
isn't accessible.

Cheers,

Cameron

"Ken Schaefer" <> wrote in message
news:...
> Is the remote server an IIS 6.0 box? If so, is WebDAV enabled?
> Does the URL requested actually exist?
>
> Cheers
> Ken
>
> "warlord" <> wrote in message
> news:...
> : I have a windows client app that is trying to download a file from
> : a web server but I always get the following error when I call the
> : GetResponse method of the Request object.
> :
> : The remote server returned an error: (404) Not Found.
> :
> : When I run it against a website on my local machine everything works
> : perfectly, but not against the remote server. I'm sure it's a security
> : or permissions problem of some sort, but I'm not sure where to start.
> :
> : The code I'm using is below.
> :
> : Thanks in advance for any help.
> :
> : Cameron
> :
> :
> : HttpWebResponse Response;
> :
> : //Retrieve the File
> : HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
> : Request.Headers.Add("Translate: f");
> : Request.Credentials = CredentialCache.DefaultCredentials;
> :
> : try
> : {
> : Response = (HttpWebResponse)Request.GetResponse();
> : }
> : catch(WebException e)
> : {
> : //Handle the exception here
> : }
> : finally
> : {
> : Response.Close()
> : }
> :
> :
>
>



 
Reply With Quote
 
John Timney \(Microsoft MVP\)
Guest
Posts: n/a
 
      04-01-2004
Could it be that you go through a proxy server normally, and your windows
app is not providing the proxy credentials?

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP


"warlord" <> wrote in message
news:e$...
> The web server is IIS 5.0, and the Url does exist. I can get to it via a
> browser without any problems - it's just from within the windows app that

it
> isn't accessible.
>
> Cheers,
>
> Cameron
>
> "Ken Schaefer" <> wrote in message
> news:...
> > Is the remote server an IIS 6.0 box? If so, is WebDAV enabled?
> > Does the URL requested actually exist?
> >
> > Cheers
> > Ken
> >
> > "warlord" <> wrote in message
> > news:...
> > : I have a windows client app that is trying to download a file from
> > : a web server but I always get the following error when I call the
> > : GetResponse method of the Request object.
> > :
> > : The remote server returned an error: (404) Not Found.
> > :
> > : When I run it against a website on my local machine everything works
> > : perfectly, but not against the remote server. I'm sure it's a

security
> > : or permissions problem of some sort, but I'm not sure where to start.
> > :
> > : The code I'm using is below.
> > :
> > : Thanks in advance for any help.
> > :
> > : Cameron
> > :
> > :
> > : HttpWebResponse Response;
> > :
> > : //Retrieve the File
> > : HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
> > : Request.Headers.Add("Translate: f");
> > : Request.Credentials = CredentialCache.DefaultCredentials;
> > :
> > : try
> > : {
> > : Response = (HttpWebResponse)Request.GetResponse();
> > : }
> > : catch(WebException e)
> > : {
> > : //Handle the exception here
> > : }
> > : finally
> > : {
> > : Response.Close()
> > : }
> > :
> > :
> >
> >

>
>



 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      04-01-2004
The browser reports the HTTP_REFERRER to the server.
And a lot of servers prevent downloading images if HTTP_REFERRER points to
different server name.

Thus preventing so called "hotlinking". When someone else site links to the
images that reside on someone else's server.

So they do not need to pay for bandwidth.

George.


"warlord" <> wrote in message
news:...
> I have a windows client app that is trying to download a file from
> a web server but I always get the following error when I call the
> GetResponse method of the Request object.
>
> The remote server returned an error: (404) Not Found.
>
> When I run it against a website on my local machine everything works
> perfectly, but not against the remote server. I'm sure it's a security
> or permissions problem of some sort, but I'm not sure where to start.
>
> The code I'm using is below.
>
> Thanks in advance for any help.
>
> Cameron
>
>
> HttpWebResponse Response;
>
> //Retrieve the File
> HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
> Request.Headers.Add("Translate: f");
> Request.Credentials = CredentialCache.DefaultCredentials;
>
> try
> {
> Response = (HttpWebResponse)Request.GetResponse();
> }
> catch(WebException e)
> {
> //Handle the exception here
> }
> finally
> {
> Response.Close()
> }
>
>



 
Reply With Quote
 
warlord
Guest
Posts: n/a
 
      04-02-2004
I thought that might be the case, but I'm providing the proxy credentials
and still no joy. In fact, I get the same error whether I provide them or
not, and when I run everything locally it works whether I provide the proxy
credntials or not.

Regards,

Cameron

"John Timney (Microsoft MVP)" <> wrote in message
news:...
> Could it be that you go through a proxy server normally, and your windows
> app is not providing the proxy credentials?
>
> --
> Regards
>
> John Timney
> Microsoft Regional Director
> Microsoft MVP
>
>
> "warlord" <> wrote in message
> news:e$...
> > The web server is IIS 5.0, and the Url does exist. I can get to it via

a
> > browser without any problems - it's just from within the windows app

that
> it
> > isn't accessible.
> >
> > Cheers,
> >
> > Cameron
> >
> > "Ken Schaefer" <> wrote in message
> > news:...
> > > Is the remote server an IIS 6.0 box? If so, is WebDAV enabled?
> > > Does the URL requested actually exist?
> > >
> > > Cheers
> > > Ken
> > >
> > > "warlord" <> wrote in message
> > > news:...
> > > : I have a windows client app that is trying to download a file from
> > > : a web server but I always get the following error when I call the
> > > : GetResponse method of the Request object.
> > > :
> > > : The remote server returned an error: (404) Not Found.
> > > :
> > > : When I run it against a website on my local machine everything works
> > > : perfectly, but not against the remote server. I'm sure it's a

> security
> > > : or permissions problem of some sort, but I'm not sure where to

start.
> > > :
> > > : The code I'm using is below.
> > > :
> > > : Thanks in advance for any help.
> > > :
> > > : Cameron
> > > :
> > > :
> > > : HttpWebResponse Response;
> > > :
> > > : //Retrieve the File
> > > : HttpWebRequest Request =

(HttpWebRequest)HttpWebRequest.Create(url);
> > > : Request.Headers.Add("Translate: f");
> > > : Request.Credentials = CredentialCache.DefaultCredentials;
> > > :
> > > : try
> > > : {
> > > : Response = (HttpWebResponse)Request.GetResponse();
> > > : }
> > > : catch(WebException e)
> > > : {
> > > : //Handle the exception here
> > > : }
> > > : finally
> > > : {
> > > : Response.Close()
> > > : }
> > > :
> > > :
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
warlord
Guest
Posts: n/a
 
      04-02-2004
I probably should add that the same windows application calls a web service
one the server without any problems - it's only trying to get the Response
stream from a new Request object.

Cheers,

Cameron

"John Timney (Microsoft MVP)" <> wrote in message
news:...
> Could it be that you go through a proxy server normally, and your windows
> app is not providing the proxy credentials?
>
> --
> Regards
>
> John Timney
> Microsoft Regional Director
> Microsoft MVP
>
>
> "warlord" <> wrote in message
> news:e$...
> > The web server is IIS 5.0, and the Url does exist. I can get to it via

a
> > browser without any problems - it's just from within the windows app

that
> it
> > isn't accessible.
> >
> > Cheers,
> >
> > Cameron
> >
> > "Ken Schaefer" <> wrote in message
> > news:...
> > > Is the remote server an IIS 6.0 box? If so, is WebDAV enabled?
> > > Does the URL requested actually exist?
> > >
> > > Cheers
> > > Ken
> > >
> > > "warlord" <> wrote in message
> > > news:...
> > > : I have a windows client app that is trying to download a file from
> > > : a web server but I always get the following error when I call the
> > > : GetResponse method of the Request object.
> > > :
> > > : The remote server returned an error: (404) Not Found.
> > > :
> > > : When I run it against a website on my local machine everything works
> > > : perfectly, but not against the remote server. I'm sure it's a

> security
> > > : or permissions problem of some sort, but I'm not sure where to

start.
> > > :
> > > : The code I'm using is below.
> > > :
> > > : Thanks in advance for any help.
> > > :
> > > : Cameron
> > > :
> > > :
> > > : HttpWebResponse Response;
> > > :
> > > : //Retrieve the File
> > > : HttpWebRequest Request =

(HttpWebRequest)HttpWebRequest.Create(url);
> > > : Request.Headers.Add("Translate: f");
> > > : Request.Credentials = CredentialCache.DefaultCredentials;
> > > :
> > > : try
> > > : {
> > > : Response = (HttpWebResponse)Request.GetResponse();
> > > : }
> > > : catch(WebException e)
> > > : {
> > > : //Handle the exception here
> > > : }
> > > : finally
> > > : {
> > > : Response.Close()
> > > : }
> > > :
> > > :
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
John Timney \(Microsoft MVP\)
Guest
Posts: n/a
 
      04-02-2004
Does the app your calling expect cookies, I'm guessing that your web service
is stateless but your web app is not. It may be trying to establish a
session and failing.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP


"warlord" <> wrote in message
news:...
> I probably should add that the same windows application calls a web

service
> one the server without any problems - it's only trying to get the Response
> stream from a new Request object.
>
> Cheers,
>
> Cameron
>
> "John Timney (Microsoft MVP)" <> wrote in message
> news:...
> > Could it be that you go through a proxy server normally, and your

windows
> > app is not providing the proxy credentials?
> >
> > --
> > Regards
> >
> > John Timney
> > Microsoft Regional Director
> > Microsoft MVP
> >
> >
> > "warlord" <> wrote in message
> > news:e$...
> > > The web server is IIS 5.0, and the Url does exist. I can get to it

via
> a
> > > browser without any problems - it's just from within the windows app

> that
> > it
> > > isn't accessible.
> > >
> > > Cheers,
> > >
> > > Cameron
> > >
> > > "Ken Schaefer" <> wrote in message
> > > news:...
> > > > Is the remote server an IIS 6.0 box? If so, is WebDAV enabled?
> > > > Does the URL requested actually exist?
> > > >
> > > > Cheers
> > > > Ken
> > > >
> > > > "warlord" <> wrote in message
> > > > news:...
> > > > : I have a windows client app that is trying to download a file from
> > > > : a web server but I always get the following error when I call the
> > > > : GetResponse method of the Request object.
> > > > :
> > > > : The remote server returned an error: (404) Not Found.
> > > > :
> > > > : When I run it against a website on my local machine everything

works
> > > > : perfectly, but not against the remote server. I'm sure it's a

> > security
> > > > : or permissions problem of some sort, but I'm not sure where to

> start.
> > > > :
> > > > : The code I'm using is below.
> > > > :
> > > > : Thanks in advance for any help.
> > > > :
> > > > : Cameron
> > > > :
> > > > :
> > > > : HttpWebResponse Response;
> > > > :
> > > > : //Retrieve the File
> > > > : HttpWebRequest Request =

> (HttpWebRequest)HttpWebRequest.Create(url);
> > > > : Request.Headers.Add("Translate: f");
> > > > : Request.Credentials = CredentialCache.DefaultCredentials;
> > > > :
> > > > : try
> > > > : {
> > > > : Response = (HttpWebResponse)Request.GetResponse();
> > > > : }
> > > > : catch(WebException e)
> > > > : {
> > > > : //Handle the exception here
> > > > : }
> > > > : finally
> > > > : {
> > > > : Response.Close()
> > > > : }
> > > > :
> > > > :
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
warlord
Guest
Posts: n/a
 
      04-06-2004
John,
The web service is actually using session state (I'm not entirely sure why
as I didn't write the service...in fact I didn't write any of it, I'm just
the luck SOB who got the job of debugging it and finishing it off) and of
course the web application is also using session state.

I have even added a separate web.config file to the folder containing the
files I'm trying to get to that explicitly sets the session state settings
(not that I need to do that) but also overrides the authenticaton and
authorization settings to use Windows authentication (impersonate is set to
true) and to allow all users - all to no avail.

Interestingly, if I disable session state for the web application the home
page still displays as it is not reliant on session at all, but when I
navigate to a page that uses session state the error I receive is the 404 -
Not Found error. Your previous reply and this is what prompted me to try
the separate config files.

I've also set the cookieless element of the sessionState setting to true but
that too makes no difference.

Any further suggestions ?

Thanks for all your help so far.

Regards,

Cameron Gibbs


"John Timney (Microsoft MVP)" <> wrote in message
news:...
> Does the app your calling expect cookies, I'm guessing that your web

service
> is stateless but your web app is not. It may be trying to establish a
> session and failing.
>
> --
> Regards
>
> John Timney
> Microsoft Regional Director
> Microsoft MVP
>
>
> "warlord" <> wrote in message
> news:...
> > I probably should add that the same windows application calls a web

> service
> > one the server without any problems - it's only trying to get the

Response
> > stream from a new Request object.
> >
> > Cheers,
> >
> > Cameron
> >
> > "John Timney (Microsoft MVP)" <> wrote in message
> > news:...
> > > Could it be that you go through a proxy server normally, and your

> windows
> > > app is not providing the proxy credentials?
> > >
> > > --
> > > Regards
> > >
> > > John Timney
> > > Microsoft Regional Director
> > > Microsoft MVP
> > >
> > >
> > > "warlord" <> wrote in message
> > > news:e$...
> > > > The web server is IIS 5.0, and the Url does exist. I can get to it

> via
> > a
> > > > browser without any problems - it's just from within the windows app

> > that
> > > it
> > > > isn't accessible.
> > > >
> > > > Cheers,
> > > >
> > > > Cameron
> > > >
> > > > "Ken Schaefer" <> wrote in message
> > > > news:...
> > > > > Is the remote server an IIS 6.0 box? If so, is WebDAV enabled?
> > > > > Does the URL requested actually exist?
> > > > >
> > > > > Cheers
> > > > > Ken
> > > > >
> > > > > "warlord" <> wrote in message
> > > > > news:...
> > > > > : I have a windows client app that is trying to download a file

from
> > > > > : a web server but I always get the following error when I call

the
> > > > > : GetResponse method of the Request object.
> > > > > :
> > > > > : The remote server returned an error: (404) Not Found.
> > > > > :
> > > > > : When I run it against a website on my local machine everything

> works
> > > > > : perfectly, but not against the remote server. I'm sure it's a
> > > security
> > > > > : or permissions problem of some sort, but I'm not sure where to

> > start.
> > > > > :
> > > > > : The code I'm using is below.
> > > > > :
> > > > > : Thanks in advance for any help.
> > > > > :
> > > > > : Cameron
> > > > > :
> > > > > :
> > > > > : HttpWebResponse Response;
> > > > > :
> > > > > : //Retrieve the File
> > > > > : HttpWebRequest Request =

> > (HttpWebRequest)HttpWebRequest.Create(url);
> > > > > : Request.Headers.Add("Translate: f");
> > > > > : Request.Credentials = CredentialCache.DefaultCredentials;
> > > > > :
> > > > > : try
> > > > > : {
> > > > > : Response = (HttpWebResponse)Request.GetResponse();
> > > > > : }
> > > > > : catch(WebException e)
> > > > > : {
> > > > > : //Handle the exception here
> > > > > : }
> > > > > : finally
> > > > > : {
> > > > > : Response.Close()
> > > > > : }
> > > > > :
> > > > > :
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
John Timney \(Microsoft MVP\)
Guest
Posts: n/a
 
      04-06-2004
> The web service is actually using session state (I'm not entirely sure why
> as I didn't write the service...in fact I didn't write any of it, I'm just
> the luck SOB who got the job of debugging it and finishing it off) and of
> course the web application is also using session state.



if thats the case, then your winforms app needs to handle the cookie asp.net
generates when you connect to the server. The server will expect the
session cookie to be passed back to it.


--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP




 
Reply With Quote
 
 
 
Reply

Thread Tools

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
regarding error "Http error-404 object not found" ashluvcadbury@gmail.com ASP .Net 0 04-16-2007 04:44 AM
Precompile.axd returns error 404 Shimon Sim ASP .Net 2 01-23-2006 09:19 AM
Intercept IIS 404 errors? Issue with Viewstate and 404 Jonathan Folland ASP .Net 2 03-17-2005 02:32 AM
HttpWebRequest.GetResponse returns 404 No Found error warlord ASP .Net 12 04-21-2004 08:54 AM
HttpWebRequest.GetResponse returns 404 No Found error warlord ASP .Net Web Services 12 04-21-2004 08:54 AM



Advertisments