Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Folks,

I have set the custom error page so that when ever some error generate then the user will be redirected to a custom error page. But my problem is that system is not showing the custom error page despite experiencing errors.

Here is the code

web.config file
===================================
XML
<customErrors mode="On" defaultRedirect="error.aspx">
      <error statusCode="500" redirect="error.aspx"/>
      <!-- Error Page -->
      <error statusCode="400" redirect="error.aspx"/>
      <!-- ASPX Page Not Found -->
    </customErrors>



===================================
General function
===================================
public DataSet GenerateDataset(string query)
    {
        
        if (conn.State == ConnectionState.Open)
            conn.Close();
        conn.Open();

        try
        {
            //adap = new OleDbDataAdapter(query, conn);
            adap = new OdbcDataAdapter(query, conn);
            ds = new DataSet();
            ds.Clear();
            adap.Fill(ds);
            return ds;
        }
        catch (Exception ex)
        {
           
            throw ex;
            
        }
        finally
        {
            adap.Dispose();
            conn.Close();
        }
    }

=======================================
Main Portion
=======================================
objGen = new GeneralFunction();
       ds = new DataSet();
       try
       {
           ds = objGen.GenerateDataset(strQuery);
           if (ds.Tables[0].Rows.Count > 0)
           {
               GridView1.DataSourceID = null;
               GridView1.DataSource = ds;
               GridView1.DataBind();
               Lbl_rc.ForeColor = System.Drawing.Color.Black;
               Lbl_rc.Font.Bold = true;
               Lbl_rc.Text = "<font color='#009933'>Total no of unconfirm orders : " + ds.Tables[0].Rows.Count + "</font>";
               trP1.Visible = true;
               GridView1.Visible = true;


           }
           else
           {
               GridView1.DataSourceID = null;
               Lbl_rc.ForeColor = System.Drawing.Color.Black;
               Lbl_rc.Font.Bold = true;
               Lbl_rc.Text = "<font color='#FF0000'>No unconfirm orders in the list.</font>";
               trP1.Visible = false;
               GridView1.Visible = false;

           }
       }
       catch(Exception ex)
       {

           Tabok.Visible = false;
           tab3.Visible = true;
           lblmsg.Visible = true;
           lblmsg.Text = "Error : " + ex.Message;

       }
       finally
       {

           strQuery = "";
           ds.Dispose();
           objGen = null;
       }


Please let me know what is wrong with above code
Posted
Updated 2-Feb-10 9:53am

There's a ton wrong with this code, however, specifically, is it throwing the error page with a 500 in it, or something else ?
 
Share this answer
 
i am getting the error in catch block but what i want is when ever error occurs it should redirect me to custom error page, which is not happening currently. please provide the direction
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900