在ASP.NET中使用window.location更改位置时会话丢失

时间:2018-10-31 22:15:04

标签: c# asp.net session session-variables

我正在显示一条消息。
像这样:

//ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", errortext + " window.location='" +
//Page.ResolveUrl("~") + newpage + "';", true);

//Response.Write("<script>" + errortext + "</script>");
//Response.Write("<script>top.location.href='" + Page.ResolveUrl("~") + newpage + "'</script>");

var page = HttpContext.Current.CurrentHandler as Page;
ScriptManager.RegisterStartupScript(page, page.GetType(), "alert", "alert('" + errortext + "');window.location ='" + Page.ResolveUrl("~") + newpage + "';", true);

注意:如您所见,我尝试了3种不同的格式。脚本重定向后,会话将丢失。页面网址几乎相同: 表示从https://whatever//hello.aspxhttps://whatever/hello2.aspx

我不能使用“ Response.Redirect”,因为那样会杀死消息。重定向确实发生了,页面出现了。但是,我很快发现该页面没有操作所需的信息。

0 个答案:

没有答案
相关问题