Urgent : Error executing child request

I'm having a default.aspx page. My application uses pages where each page has a pageid and each pageid follows a template format. Each template format is created as template1.aspx, template2.aspx..etc..

But in my url when i type http://localhost/mydomain/default.aspx?pageid=122 then default.aspx check the pageid and redirects to the template page (say Template5.aspx) and then it should not show http://localhost/mydomain/Template5.aspx?pageid=122  but  http://localhost/mydomain/default.aspx?pageid=122. Inorder to acheive this, i'm following this code in my default.aspx page.

I'm using Server.Transfer to acheive this url format.

But when i use this, it gives 'Error executing child request for template5.aspx' error.


default.aspx.cs:
--------------

      private void Page_Load(object sender, System.EventArgs e)
            {
                  try
                  {
                        if (!Page.IsPostBack)
                        {
                              if(Request.QueryString["Flag"]!=null)
                              {
                                    if (Convert.ToBoolean(Request.QueryString["Flag"])==true)
                                    {
                                          Server.Transfer("Search.aspx");
                                    }
                                    else
                                    {
                                          Server.Transfer("Search.aspx");
                                    }
                              }
                              if (Request.QueryString["Pageid"]==null)
                              {
                                    HomepageId=Convert.ToInt32(ConfigurationSettings.AppSettings["HomepageId"]);
                                    HomeTemplateId=Convert.ToInt32(ConfigurationSettings.AppSettings["HomeTemplateId"]);
                                    ipageid=HomepageId;
                                    iTemplateid=HomeTemplateId;
                              }
                              else
                              {
                                    ipageid=Convert.ToInt32(Request.QueryString["Pageid"]);
                                    iTemplateid = objTemp.GetTemplateid(ipageid);
                              }
                              Session["ipageid"]=ipageid;
                              Session["iTemplateid"]=iTemplateid;

                              if(Request.QueryString["Year"]!=null)
                              {
                                    Server.Transfer("Template"+iTemplateid+".aspx");
                              }
                              else if((Request.QueryString["bselected"]!=null) && (Request.QueryString["Index"]!=null))
                              {
                                    Server.Transfer("Template"+iTemplateid+".aspx");
                              }
                              else
                              {
                                    Server.Transfer("Template"+iTemplateid+".aspx");
                              }
                              if(Request.Url.ToString().IndexOf("Template",1)>0)
                              {
                                    Server.Transfer("Template"+iTemplateid+".aspx");
                              }
                        }
                  }
                  catch(Exception ex)
                  {
                        if(ex !=null)
                        {
                              //this.lblMessage.Text =Utility.ErrorCall("ERR_UNIDFD_ERROR");                        
                              //lblMessage.Visible = true;
                        }
                  }
            }
poobalanr072299Asked:
Who is Participating?
 
the_paabCommented:
When you use the Server.Transefer then url in browser is not changed because page change pass on server (and client don't know about it). Use Response.Redirect instead, then the address will be changed as you need, because page change happens on clinet side.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.