how to programmatically decide which content page to load , on master page load
-
30-10-2019 - |
Question
I have a master page and two content pages with the same ContentPlaceHolderID. Is there a way to specify which content page should be loaded from the Page_Load
event of the master page?
If I watch the value of:
Request.CurrentExecutionFilePath;
I see the path of the first content page.
According to the condition specified below i want to change it to the path of the second content page.
I am looking for a way to load a specific page depending on a check I do on the Master Page_Load
.
If I attempt to redirect to the page from there I get stuck in an endless loop because the master page loads again before the content page and re-does the check and redirects again and again.
// in master page
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Cookies["user"] != null)
{
HttpCookie cookie = Request.Cookies["user"];
string name = cookie.Value;
Response.Redirect("~/hello_page.aspx?UserName=" + name);
}
}
}
Thanks in advance.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow