远程服务器返回错误:(404)在asp.net中找不到? [英] The remote server returned an error: (404) Not Found in asp.net?

查看:86
本文介绍了远程服务器返回错误:(404)在asp.net中找不到?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 HttpWebResponse myResp =(HttpWebResponse)myReq.GetResponse(); 
//向控制台显示页面内容。
Stream streamResponse = myResp.GetResponseStream();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();









error显示在

 HttpWebResponse myResp =(HttpWebResponse)myReq.GetResponse(); 





请帮助我..

解决方案

首先,您需要了解Web应用程序最重要的部分:服务器上发生了什么,客户端会发生什么?

您显示有关WebResponse的代码。 WebResponse是对WebRequest的响应。 WebRequest从服务器请求URL(可能带有一些参数)。

当服务器返回404消息时,发生了什么?

它找不到客户端请求的URL。

这就是它:查看请求的URL。它是否存在于服务器上?显然不是。那么:它有什么问题?怎么打错字?

请记住:当你没有提供决定性的信息点时,我们提供帮助的可能性非常有限。


请检查myReq,一些你可能错过的东西,

当你的请求不存在或你在请求中缺少某些内容时会出现此错误。

如果请求不存在将如何获得响应。

HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
        // Display the contents of the page to the console.
        Stream streamResponse = myResp.GetResponseStream();
        System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
        string responseString = respStreamReader.ReadToEnd();
        respStreamReader.Close();
        myResp.Close();





error showing on

HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();



pls help me..

解决方案

First you need to understand the most important part of web applications: what happens on the server, what happens on the client?
You show code regarding a WebResponse. A WebResponse is a response to a WebRequest. A WebRequest requests a URL (perhaps with some parameters) from the server.
When a server returns a 404 message, what did happen?
It did not find the URL requested by the client.
And that's it: Look at the requested URL. Does it exist on the server? Obviously not. So: what's wrong with it? What about a typo?
Remember: when you do not provide the decisive points of information, our possibilities to help are very limited.


Please check myReq, some thing you may miss,
This error comes when your request is not present or you are missing something in request,
if request is not present how it will get the response.


这篇关于远程服务器返回错误:(404)在asp.net中找不到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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