I have found a lot of examples but I don't know why these are not working for me. I have tried these but in vain.
I have also tried the following:
String message = "Session Expired! Log In Again.";
ClientScript.RegisterStartupScript(
this.GetType(),
Guid.NewGuid().ToString(),
string.Format("alert('{0}');window.location.href = 'default.aspx'",
message.Replace("'", @"\'").Replace("\n", "\\n").Replace("\r", "\\r")),
true);
and
ScriptManager.RegisterStartupScript(
this,
this.GetType(),
"redirect",
"alert('Session Expired! Log In Again.');
window.location='" + Request.ApplicationPath + "Account/login.aspx';",
true);
and
Response.Write("
<script language='javascript'>
window.alert('Session Expired');
window.location='~/Account/Login.aspx';
</script>");
but all of these are not redirecting to the login page just showing the alert message.
try this
window.location.href="Account/Login.aspx";
remove ~ operator from the path
Try this
Response.Write("<script language='javascript'>window.alert('Popup message ');window.location='webform.aspx';</script>");
Change location and message.
Happy coding Regards, AK.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.