访问页面时,我正在存储会话状态的值。当我点击浏览器时,会话中的值恢复为原始值。为什么会发生?当我回去时,我不会重置价值。会话状态问题
这发生在iPhone和iPad上 - 所有其他浏览器都不回滚会话状态值。
在此先感谢。
我使用这个JavaScript代码(在两个页面代码是相同的):
function pageLoad() {
// Get the current url path
var url = document.URL;
PageMethods.IsNavigatingBackward(url, handleCallback);
}
function handleCallback(isBackward) {
if (isBackward) {
// Go back to previous page
history.back();
}
else {
// Set the current url in the session
var url = document.URL;
PageMethods.SetCurrentPage(url, getLocation);
}
}
而后面的代码:
[WebMethod]
public static bool IsNavigatingBackward(Uri url)
{
string currentPath = url.LocalPath;
string lastPath = (string)HttpContext.Current.Session["LastPage"];
bool isBackward = false;
NavigationList table = NavigationList.GetInstance();
if (table.IsBackwardNavigation(currentPath, lastPath))
{
isBackward = true;
}
return isBackward;
}
[WebMethod]
public static void SetCurrentPage(Uri url)
{
HttpContext.Current.Session["LastPage"] = url.LocalPath;
}
给我们一些代码,你确定变量没有存储在视图状态? – Peter