将err.message作为参数传递给index.aspx,在index.aspx中接收并显示就可以了

解决方案 »

  1.   

    有个Server.GetLastError()不知道怎么用的!
      

  2.   

    1、在Global.asax中的Application_Error函数中实现异常信息捕获:
    protected void Application_Error(Object sender, EventArgs e)
    {
    Exception lastErr = Server.GetLastError;
    Session["CurrentErrMsg"] = lastErr.Message;
    }
    2、在web.config中设置:
    <customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.aspx">
    <error statusCode="500" redirect="ErrorPage500.aspx" />
    </customErrors>
    3、在ErrorPage500.aspx的Page_Load函数中实现:
    private void Page_Load(object sender, System.EventArgs e)
    {
        string errMsg = (string)Session["CurrentErrMsg"];
        //然后显示errMsg到界面上
    }