【发布时间】:2017-06-16 16:31:25
【问题描述】:
我想调用 LogOut 操作方法,因为会话超时,我还没有创建它的视图。
我已经为会话超时编写了一个脚本,但我不知道如何调用操作方法,因为我拥有的所有方法(如 window.location 等)都可以定位视图。
<script>
//session end
var sessionTimeoutWarning = @Session.Timeout;
var sTimeout = parseInt(sessionTimeoutWarning) * 60 * 1000-55000;
setTimeout('SessionEnd()', sTimeout);
/* Here I want To call that AgentLogOut Method*/
function SessionEnd() {
alert("Session Is Going To End in 1 min Please Login Again1");
window.location = "/Agent/AgentLogIn";
}
</script>
这是我要调用的目标控制器操作
public ActionResult AgentLogOut()
{
string SessionId = Session["LogInSession"].ToString();
string OType = "LogOut";
ProcedureName = "SP_Crud";
XElement xl = new XElement("data",
new XAttribute("otype", OType),
new XElement("sessionId", SessionId),
new XElement("agentIp", AgentIp)
);
objDal.ExecuteNonQuery(ProcedureName, CommandType.StoredProcedure, new MySqlParameter("@xml", xl.ToString()));
Session.Clear();
Session.Abandon();
return RedirectToAction("AgentLogIn","Agent");
}
我已经尝试了所有我知道的方法。建议我如何只点击操作方法。
【问题讨论】:
-
您是否在同一个项目中使用了控制器和视图?
-
你遇到了什么问题?
-
还带来了一些关于
SessionEnd()功能的信息。它会正常工作吗? -
您从哪里调用
AgentLogOut操作?您的 js 正在将window.location设置为AgentLogIn操作 -
@Corporalis 我在会话超时时调用它,以便在会话结束时注册注销时间。
标签: javascript c# asp.net-mvc session actionmethod