I wanted something like this (this one does not work). Error "The 'MasterPageFile' property can only be set on or before the 'Page_PreInit' event."
foreach (DataRow item in dt.Rows)
{
if (item["tipoLogin"].ToString().Contains("admin"))
{
MasterPageFile = "~/MasterPage.master";
Response.Redirect("HomeAdmin.aspx");
}
else
{
if (item["tipoLogin"].ToString().Contains("gestor"))
{
MasterPageFile = "~/MasterGestor.master";
Response.Redirect("HomeGestor.aspx");
}
else
{
if (item["tipoLogin"].ToString().Contains("responsavel"))
{
MasterPageFile = "~/MasterPageResponsavel.master";
Response.Redirect("HomeResponsavel.aspx");
}
}
}
}
Thank you