I have a problem: when i call a Response.Redirect() from the MasterPage it doesn't work. Well, debugging i can see that until the Pre_Render() method the target page is loaded, but then is rendered the previous page.
Here's some code to better explain:
(from MasterPageMain.master.cs)
protected void Page_Init(object sender, EventArgs e)
{
string m_QueryStringValue = Request.QueryString.Get("action");
if ((!string.IsNullOrEmpty(m_QueryStringValue)) && (m_QueryStringValue.ToLower() == "send"))
{
if (Session["to"] != null && Session["to"] is List<string>) this.SendPageByMail();
else
{
Session.Add("AddressToSend", Request.RawUrl);
Response.Redirect("~/chooseRecipients.aspx");
}
}
}
I have a javascript that adds the querystring adding "action=send" when i click on the Send button.
If i am on page "~/somethingInterestingToSend()" -for example- i want to get on the recipient selection page, but when i click the Send button i see always the same page.
What coul be the mistake?
If you want to redirect not logged in users to a login-page you should check the Request.RawUrl() like this:
string strURL=Request.RawUrl.ToUpper();
if (!strURL.Contains("LOGIN.ASPX") && !strURL.Contains("LOGOUT.ASPX")
&& !strURL.Contains("ERROR.ASPX") && !strURL.Contains("UNDERCONSTRUCTION.ASPX"))
{
Response.Redirect("~/Login.aspx", false);
}
All other sites will be redirected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With