HttpWebRequest.GetResponse返回404 No Found错误 [英] HttpWebRequest.GetResponse returns 404 No Found error

查看:233
本文介绍了HttpWebRequest.GetResponse返回404 No Found错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows客户端应用程序试图从

a web服务器下载文件,但是当我调用

GetResponse方法时,我总是得到以下错误请求对象。


远程服务器返回错误:(404)Not Found。


当我在本地网站上运行它时机器一切正常工作

完美,但不能对抗远程服务器。我确定这是一个安全

或某种权限问题,但我不知道从哪里开始。


代码我在下面使用。


提前感谢您的帮助。


Cameron

HttpWebResponse回复;


//检索文件

HttpWebRequest Request =(HttpWebRequest)HttpWebRequest.Create(url);

Request.Headers .Add(" Translate:f");

Request.Credentials = CredentialCache.DefaultCredentials;


try

{

响应=(HttpWebResponse)Request.GetResponse();

}

catch(WebException e)

{

//在这里处理异常

}

最后

{

回应。关闭()

}

解决方案

远程服务器是IIS 6.0的盒子吗?如果是这样,是否启用了WebDAV?

请求的URL是否确实存在?


干杯

Ken


" warlord" < SM ********* @ hotmail.com>在消息中写道

新闻:uU ************** @ tk2msftngp13.phx.gbl ...

:我有一个窗户试图从

下载文件的客户端应用程序:Web服务器但是当我调用Request对象的

:GetResponse方法时,我总是会收到以下错误。 br />


:远程服务器返回错误:(404)Not Found。



:当我对我本地机器上的网站运行它一切正常工作

:完美,但不是针对远程服务器。我确定它是安全的

:或某种权限问题,但我不知道从哪里开始。



:我正在使用的代码如下。



:提前感谢您的帮助。



:Cameron





:HttpWebResponse响应;



://检索文件

:HttpWebRequest Request =(HttpWebRequest)HttpWebRequest.Create(url);

:Request.Headers.Add(" ;翻译:f");

:Request.Credentials = CredentialCache.DefaultCredentials;



:尝试

:{

:响应=(HttpWebResponse)Request.GetResponse();

:}

:catch(WebException e)

:{

://处理例外这里

:}

:最后

:{

:Response.Close()

:}





Web服务器是IIS 5.0,并且Url确实存在。我可以通过

浏览器轻松访问它 - 它只是在Windows应用程序中,它是无法访问的。

无法访问。


干杯,


Cameron


" Ken Schaefer" <柯******* @ THISadOpenStatic.com>在消息中写道

news:eD ************** @ TK2MSFTNGP11.phx.gbl ...

远程服务器是IIS 6.0盒子?如果是这样,是否启用了WebDAV?
请求的URL是否确实存在?

Ken

" warlord" < SM ********* @ hotmail.com>在消息中写道
新闻:uU ************** @ tk2msftngp13.phx.gbl ...
:我有一个试图下载的Windows客户端应用程序来自
的文件:Web服务器,但是当我调用Request对象的
:GetResponse方法时,我总是得到以下错误。

:远程服务器返回错误: (404)Not Found。

:当我在本地机器上的网站上运行它时,一切正常,但不是远程服务器。我确定它是安全的
:或某种权限问题,但我不知道从哪里开始。

:我正在使用的代码在下面。

:提前感谢您的帮助。

:Cameron


:HttpWebResponse响应;

://检索文件
:HttpWebRequest Request =(HttpWebRequest)HttpWebRequest.Create(url);
:Request.Headers.Add(" Translate:f") ;
:Request.Credentials = CredentialCache.DefaultCredentials;

:尝试
:{
:Response =(HttpWebResponse)Request.GetResponse();
:}
:catch(WebException e)
:{
://在这里处理异常
:}
:最后
:{
:Response.Close()
:}




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()
}

解决方案

Is the remote server an IIS 6.0 box? If so, is WebDAV enabled?
Does the URL requested actually exist?

Cheers
Ken

"warlord" <sm*********@hotmail.com> wrote in message
news:uU**************@tk2msftngp13.phx.gbl...
: 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()
: }
:
:


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" <ke*******@THISadOpenStatic.com> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...

Is the remote server an IIS 6.0 box? If so, is WebDAV enabled?
Does the URL requested actually exist?

Cheers
Ken

"warlord" <sm*********@hotmail.com> wrote in message
news:uU**************@tk2msftngp13.phx.gbl...
: 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()
: }
:
:



这篇关于HttpWebRequest.GetResponse返回404 No Found错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆