请问怎样解决"服务器返回状态Internal Server Error" ?

runnery1984 2007-05-26 04:03:23
我运行以下的程序,有时候是可以正常运行的,但有时就提示 "服务器返回状态Internal Server Error" ,请问为什么?

客户端:

<html xmlns:v="http://www.eglic.com/">
<head>
<title>页面画线</title>
<meta name="ContentType" content="text/html" />
<meta name="CharSet" content="GB2312" />


<script type ="text/javascript" language ="javascript" >
var req; //定义变量,用来创建xmlhttprequest对象

function creatReq() // 创建xmlhttprequest,ajax开始
{
var url="ajaxServer.aspx"; //要请求的服务端地址
if(window.XMLHttpRequest) //非IE浏览器,用xmlhttprequest对象创建
{
req=new XMLHttpRequest();
}
else if(window.ActiveXObject) //IE浏览器用activexobject对象创建
{
req=new ActiveXObject("Microsoft.XMLHttp");
}

if(req) //成功创建xmlhttprequest
{
req.open("GET",url,true); //与服务端建立连接(请求方式post或get,地址,true表示异步)
req.onreadystatechange = callback; //指定回调函数
req.send(null); //发送请求
}
}

function callback() //回调函数,对服务端的响应处理,监视response状态
{
if(req.readystate==4) //请求状态为4表示成功
{
if(req.status==200) //http状态200表示OK
{

drawCanvas(); //所有状态成功,执行此函数,显示数据
}
else //http返回状态失败
{
alert("服务端返回状态" + req.statusText);
}
}
else //请求状态还没有成功,页面等待
{
document .getElementById ("myTime").innerHTML ="数据加载中";
}
}

setInterval('creatReq()',2000);

</script>

<script language="javascript">var Working=false;
var points = [];
var lastPoint = {x:0,y:0};


function drawCanvas()
{
var arr = eval(req.responseText);
var x1 = arr[0];
var y1 = arr[1];
if(!Working){
document.getElementById("show").style.display="none";
Working=true;
lastPoint.x = x1;
lastPoint.y = y1;
points.push( {x:x1,y:y1} );

}else{
var s='<v:line from="'+lastPoint.x+','+lastPoint.y+'" to="'+x1+','+y1+'" style="position:absolute;left:0px;top:0px;"></v:line>';
lastPoint.x = x1;
lastPoint.y = y1;
points.push( {x:x1,y:y1} );

var o=document.createElement(s);
document.body.insertAdjacentElement('BeforeEnd',o);
}
}
</script>

<style type="text/css">
v\:* {behavior:url(#default#VML);}
</style>
</head>
<body>
<div id="myTime"></div>
<input id="Button1" type="button" value="Get Time" onclick ="creatReq();"/>
<div id="show" style="border:5px solid #000;width:200px;height:30px;line-height:30px;text-align:center;display:none">
</div>
</body>
</html>

服务器端:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.SessionState;

public partial class _Default : System.Web.UI.Page
{

Random a = new Random();
int t;
int d;

protected void Page_Load(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(1000);



t = a.Next(0, 100); //从0到100的随机数
d = a.Next(0, 100); //从0到100的随机数

Response.Write(string.Format("[{0},{1}]", t, d));
Response.End();



}
}

...全文
2232 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
numberonesurf 2007-05-29
  • 打赏
  • 举报
回复
帮顶
runnery1984 2007-05-26
  • 打赏
  • 举报
回复
怎样解决这问题?
runnery1984 2007-05-26
  • 打赏
  • 举报
回复
谢谢以上各位,你们说的我都做了,还是不行
phoenixsbk 2007-05-26
  • 打赏
  • 举报
回复
System.Threading.Thread.Sleep(1000);去掉试下?
amandag 2007-05-26
  • 打赏
  • 举报
回复
一般来说返回Internal Server Error没什么好的解决方案

因为它等于告诉了你,我出错了,但并没有提供错误信息
runnery1984 2007-05-26
  • 打赏
  • 举报
回复
ajaxServer.aspx就是上面的服务器端,程序有时候是可以正常运行的,但有就提示 "服务器返回状态Internal Server Error" ,请问为什么?
weizhuangzhi 2007-05-26
  • 打赏
  • 举报
回复
IE 工具 internet选项 高级 显示友好Http错误信息 去掉勾选
phoenixsbk 2007-05-26
  • 打赏
  • 举报
回复
应该是500错误,检查一下你的ajaxServer.aspx有什么问题
runnery1984 2007-05-26
  • 打赏
  • 举报
回复
我的是server 2003, 和vs2005

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧