[英]Not able re-login after session timeout in asp.net mvc4 application
the code in global.asax is global.asax中的代码是
protected void Session_Start(Object sender, EventArgs e)
{
Session["init"] = 0;
}
protected void Session_End(Object sender, EventArgs e)
{
Session.Clear();
}
and in web.config file is 并在web.config文件中
<sessionState mode="InProc" cookieless="false" timeout="10" customProvider="DefaultSessionProvider">
and after session time out login page is displayed. 会话超时后,将显示登录页面。 User enters the field and clicks the login button.
用户进入该字段并单击登录按钮。 on login button an ajax post is called as
在登录按钮上,ajax帖子被称为
$.ajax({
type: 'POST',
url: 'Main/BoolLogin',
data: { username: $("#userName").val(), pwd: $("#password").val() }
});
Initially this call is working fine at the application start up but after session timeout on clicking the login button 最初,此调用在应用程序启动时正常工作,但在单击登录按钮后会话超时之后
This error is displayed 显示此错误
Failed to load resource: the server responded with a status of 404 (Not Found) 无法加载资源:服务器响应状态为404(未找到)
I am new to sessions. 我是新来的会议。 Please Help.
请帮忙。
It's because of relative URLs. 这是因为相对的URL。 Your URL starts without slash, that means it would be resolved relatively to current.
您的网址没有斜线,这意味着它将相对于当前进行解析。
url: 'Main/BoolLogin',
When user is logged out your URL probably changes to something like that: http://domain.com/Auth/Login . 当用户注销时,您的URL可能会更改为: http : //domain.com/Auth/Login 。 So you get http://domain.com/Auth/Login/Main/BoolLogin instead of http://domain.com/Main/BoolLogin .
所以你得到http://domain.com/Auth/Login/Main/BoolLogin而不是http://domain.com/Main/BoolLogin 。
Start your URL with slash or better use @Url.Action helper. 使用斜杠开始您的网址或更好地使用@ Url.Action帮助程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.