protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request["id"] != null && !string.IsNullOrEmpty(Request["id"].ToString())) { //启用该句会引发ajax超时异常 // System.Threading.Thread.Sleep(3000); Response.Write(GetData(Request["id"].ToString())); } } } protected string GetData(string id) { string str = string.Empty; switch (id) { case "1": str += "This is Number 1"; break; case "2": str += "This is Number 2"; break; case "3": str += "This is Number 3"; break; default: str += "Warning Other Number!"; break; } return str; }
运行程序,结果如图: