ASP.NET 远程服务器返回错误: (500) 内部服务器错误。求高手帮助
远程服务器返回错误: (500) 内部服务器错误。说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Net.WebException: 远程服务器返回错误: (500) 内部服务器错误。
源错误:
行 42: //System.Web.HttpContext.Current.Response.Write(NewUrl);
行 43: //System.Web.HttpContext.Current.Response.End();
行 44: Byte[] pageData = wc.DownloadData(NewUrl);
行 45: retVal = Encoding.GetEncoding("gb2312").GetString(pageData);
行 46: string[] Turl = url.Split('/');
堆栈跟踪:
[WebException: 远程服务器返回错误: (500) 内部服务器错误。]
System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) +362
System.Net.WebClient.DownloadData(Uri address) +181
System.Net.WebClient.DownloadData(String address) +90
GetHtml.ChangeHtml(String url, String Dlist) in c:\Documents and Settings\Administrator\桌面\化通社\化通社\App_Code\GetHtml.cs:44
ForHit.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\Administrator\桌面\化通社\化通社\ForHit.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +31
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +68
System.Web.UI.Control.OnLoad(EventArgs e) +88
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3025
分数不多,请高手帮帮忙。
--------------------编程问答-------------------- 500错误的原因是很多的
获取数据的地址是否正确,是否能打开
抓包工具
获取数据的地址是否正确,是否能打开
public String GetPageCode(String PageURL, String Charset)
{
String strHtml = "";
try
{
HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create(PageURL);
wreq.Method = "GET";
wreq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8";
HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse();
Stream s = wresp.GetResponseStream();
StreamReader objReader = new StreamReader(s, System.Text.Encoding.GetEncoding(Charset));
strHtml = objReader.ReadToEnd();
objReader.Close();
return strHtml;
}
catch(WebException ex)
{
HttpWebResponse res = ex.Response as HttpWebResponse;
if (res.StatusCode == HttpStatusCode.InternalServerError)
{
Stream s = res.GetResponseStream();
StreamReader objReader = new StreamReader(s, System.Text.Encoding.GetEncoding(Charset));
strHtml = objReader.ReadToEnd();
objReader.Close();
}
else
{
strHtml = ex.Message;
}
return strHtml;
}
} --------------------编程问答-------------------- 这种错误的原因有很多的喔。有可能是你代码错了或者其他原因。 --------------------编程问答-------------------- 像这种错误还是学会调试吧
补充:.NET技术 , ASP.NET