DestinationPageUrl
is the default destination page after Login.
?ReturnUrl
is stronger than DestinationPageUrl
so, if it is set it wins.
Response.Redirect
in LoginUser_LoggedIn
is stronger than ReturnUrl
so, if you want to override ReturnUrl
you must use this code:
void LoginUser_LoggedIn(Object sender, EventArgs e)
{
Response.Redirect("~/mycustompage.aspx");
....
}
DestinationPageUrl
should be set in the aspx page
<asp:Login DestinationPageUrl="~/mycustompage.aspx" ... />
or in Page_Load
event to work properly.
void PageLoad(Object sender, EventArgs e)
{
LoginUser.DestinationPageUrl = "~/mycustompage.aspx";
....
}
If you must change the destination page after login (in example if the page changes depending on the user or the user's role) you must use Server.trasfer()
ore Response.Redirect()
.
void LoginUser_LoggedIn(Object sender, EventArgs e)
{
Response.Redirect("~/mycustompage.aspx");
....
}