我在移动Safari iOS 6中遇到了通过AJAX设置的会话变量的问题.我提供了一个示例,它将设置会话变量,重定向到另一个页面,放弃会话并重新开始.这前两次工作正常.在第三次通过该过程时,会话变量丢失.问题只发生在iOS 6 safari中.它适用于我尝试过的所有其他浏览器.
该样本包含3页.Page1设置会话变量并重定向到第2页.Page 2显示会话变量.第3页放弃了会话变量.
第1页HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="sm" runat="server" EnablePageMethods="true">
<Scripts>
<asp:ScriptReference Path="~/Page1.js" />
</Scripts>
</asp:ScriptManager>
<div onclick="setSessionVariable()">Set session variable and redirect to page 2</div>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
第1页Javascript:
function setSessionVariable() {
PageMethods.SetSessionVariable(displaySetSessionVariable);
}
function displaySetSessionVariable(bReturn) {
window.location = "Page2.aspx";
}
Run Code Online (Sandbox Code Playgroud)
第1页代码:
using System.Web.Services;
namespace SafariSessionProblem {
public partial class Page1 : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
[WebMethod]
public …Run Code Online (Sandbox Code Playgroud)