【发布时间】:2018-03-07 02:03:00
【问题描述】:
我目前在 asp.net vb 中支持基于 Web 的应用程序。下面这部分代码用于检查会话并在会话到期后自动注销用户。另外,我有一个安全窗口,它会在成功登录时弹出,并在刷新或关闭此弹出窗口时注销用户。
问题是每当 javascript 调用 MasterPage.master.vb 中的函数时,我都会收到错误消息 "MasterPage is Undefined"。错误发生在代码MasterPage.LogOn()、MasterPage.GetClientSession() 等。
下面是我在 MasterPage.master 文件中的 javascript,函数 LogOn()、GetClientSession() 和其他函数在 MasterPage.master.vb 文件中。
此问题仅在测试服务器上部署系统时出现,并且在我的本地 PC 上运行良好。
请任何可以提供帮助的人。非常感谢。
<script type="text/javascript" language="JavaScript">
var SessionTime = 0;
var uname = "";
var status = "";
var clientSession = 0;
var spyOn;
function logon()
{
MasterPage.LogOn();
clientSession = MasterPage.GetClientSession().value;
spyOn = MasterPage.spyOn().value;
setTimeout("CheckSession()", 60000);
if (!spyOn)
{
var spyWin = open('spy.aspx','UserSecurity','width=250,height=100,left=2000,top=2000,status=0,scrollbar=no,titlebar=no,toolbar=no');
}
}
function CheckSession()
{
SessionTime = SessionTime + 1;
if (SessionTime >= clientSession)
{
var uname = document.getElementById("ctl00_hdnUser").value;
var status = document.getElementById("ctl00_hdnStatus").value;
var x = MasterPage.SessionEnded(uname, status).value;
alert(x);
window.open("Login.aspx","_self");
}
setTimeout("CheckSession()", 60000);
}
function RorC()
{
var top=self.screenTop;
if (top>9000)
{
window.location.href="logout.aspx" ;
}
}
function LogMeOut()
{
window.location.href="logout.aspx" ;
}
function ShowTime()
{
var dt = new Date();
document.getElementById("<%= Textbox1.ClientID %>").value = dt.toLocaleTimeString();
window.setTimeout("ShowTime()", 1000);
MasterPage.CheckSession(CheckSession_CallBack);
}
window.setTimeout("ShowTime()", 1000);
function CheckSession_CallBack(response)
{
var ret = response.value;
if (ret == "")
{
isClose = true;
window.location.href="login.aspx"
}
}
</script>
【问题讨论】:
-
已通过在支持 IIS7 的 web.config 上添加处理程序(
部分下的 和 部分下的 )解决此问题,并设置应用程序池在 IIS 管理器上从“集成”到“经典”。 -
很高兴您能够自己解决此问题,对于以后可能正在搜索此问题的其他人,您能否以答案的形式提交您的答案?可以自己回答问题!
标签: javascript asp.net vb.net