Not redirecting! Exception generated

coolsaint

New Member
\[code\]protected void Page_Load(object sender, EventArgs e){ try { Literal litMenu = this.Master.FindControl("litMenu") as Literal; litMenu.Text = "<table width=\"980\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" + "<tr>" + "<td align=\"left\"><a id=\"s1\" href=http://stackoverflow.com/"index.aspx\" title=\"Home\"><span>Home</span></a></td>" + "<td align=\"left\"><a id=\"s2\" href=http://stackoverflow.com/"stock_medals_category.aspx\" title=\"Sport Medals\"><span>Sport Medals</span></a></td>" + "<td align=\"left\"><a id=\"s3\" href=http://stackoverflow.com/"diecast_medals_product.aspx\" title=\"Custom Medals\"><span>Custom Medals</span></a></td>" + "<td align=\"left\"><a id=\"s4\" href=http://stackoverflow.com/"diecast_coin_product.aspx\" title=\"Award Coins\"><span>Award Coins</span></a></td>" + "<td align=\"left\"><a id=\"s5\" href=http://stackoverflow.com/"color_magic_medals_category.aspx\" title=\"Last-Minute Custom Medals\"><span>Last-Minute Custom Medals</span></a></td>" + "<td align=\"left\"><a id=\"s6\" href=http://stackoverflow.com/"contact_us.aspx\" title=\"Customer Service\"><span>Customer Service</span></a></td>" + "<td align=\"left\"><a id=\"s7\" href=http://stackoverflow.com/"#\" title=\"FAQ\"><span>FAQ</span></a></td></tr></table>"; if (!Page.IsPostBack) { if (Session["Keyword"] != null) { string keyword = Convert.ToString(Session["Keyword"]); if ((keyword == "custom") || (keyword == "custom medals")) { Response.Clear(); Response.Redirect("http://" + domain + "/product1.aspx", false); } else if ((keyword == "custom coins") || (keyword == "custom coin") || (keyword == "award coin") || (keyword == "award coins") || (keyword == "Premium Custom Minted Coins") || (keyword == "Premium Custom Minted Coin") || (keyword == "Custom Minted Coins") || (keyword == "Custom Minted Coin")) { Response.Clear(); Response.Redirect("http://" + domain + "/product2.aspx", false); } else { objB_Products.Keyword = keyword; searchds = objB_Products.getSearchResult(); if (searchds.Tables[0].Rows.Count > 0) { dlSearchList.DataSource = searchds; dlSearchList.DataBind(); } else { lblSearchResults.Visible = true; lblSearchResults.Text = "No Search Results Found!"; } } } Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); } } catch (Exception ex) { HtmlGenericControl divMessage = this.Master.FindControl("divMessage") as HtmlGenericControl; Label lblMessage = this.Master.FindControl("lblMessage") as Label; divMessage.Attributes["style"] = "display:block; width: 703px; height: 20px; text-align: center;"; lblMessage.CssClass = "errormessage"; lblMessage.Text = ex.Message.ToString(); }}\[/code\]The redirection does not work properly in accordance with the conditions.An Exception occurs :unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
 
Back
Top