How to make a server.transfer() with a Response.AddHeader("refresh", "seconds") and not get a 404 er
- by Unlimited071
Hi all, so this is the scenario:
I have a base class for all login-controlled pages:
public class SessionControlledPage : Page
{
protected virtual void Page_Load(Object sender, EventArgs e)
{
Response.AddHeader("Refresh", Convert.ToString(Session.Timeout * 60 + 5));
if (Session.IsNewSession)
{
Response.Redirect("~/login.aspx");
}
}
}
And a regularpage.aspx page that inherints from the base class:
public partial class RegularPage : SessionControlledPage
{
override protected void Page_Load(Object sender, EventArgs e)
{
base.Page_Load(sender, e);
Server.Transfer("~/otherpage.aspx");
}
}
Now let's say the original URL was http://localhost/regularpage.aspx and that Session.Timeout = 5. The problem appears when the refresh happens after the transfer takes place. I'm getting a 404 Not Found error and the URL changes for http://localhost/305. Notice that 5 * 60 + 5 = 305.
Do you know why is this happening? got a solution?
PD: I use transfer because I need to access some properties of regularpage.aspx on otherpage.aspx, maybe you could provide another solution for this too.