ASP.NET MVC实体框架4.3中数据库调用的会话超时 [英] Session timeout on database call in ASP.NET MVC Entity Framework 4.3
问题描述
我正在使用Entity Framework 4.3为数据库在ASP.NET MVC3中开发分类广告应用程序。
我在用户会话处于活动状态时遇到问题并执行任何数据库按实体框架查询然后应用程序会话时间意外地出来。
请注意,查询成功执行,我也可以看到我的结果但是过了一会儿asp.net会话终止。
只有当我将我的应用程序托管到实时服务器(Arvixe)时才会发生这种情况。在我的本地IIS上它工作正常。
如果我使用任何其他来源进行数据库查询,那么它工作正常。
我还在web.config中重置了会话超时。我正在使用MYSQL。有什么想法吗?
我使用这种简单的登录方式,它工作正常..
< pre lang =xml> using(Html.BeginForm(ValidateLogin,User,FormMethod.Post))
{
< div >
< 输入 type = text name = LoginName id = LoginName / >
< input 类型 = 密码 name = 密码 id = 密码 / < span class =code-keyword>>
< p >
< 输入 type = 复选框 名称 = RememberMe / > < span > 还记得吗?< / span > < / p >
< input id = Submit1 类型 = 提交 value = submit / >
< / div >
}
[HttpPost]
public ActionResult ValidateLogin(string LoginName,string Password,string RememberMe)
{
User aUser = new < span class =code-keyword>用户(); //用户类
var userList = db.Users。其中(u =>(u.Loginname.ToLower()== name.ToLower() || u.Email == name)&& u.Password == password);
if (Users.Count()> 0 )
{
aUser = Users.Take( 1 )。Single();
Session。添加( user,aUser.UserId);
return RedirectToAction( Index, Home);
}
else
{
return RedirectToAction( 登录, 用户,new {error = login} );
}
你设置了很长的超时时间吗?它是超时的,还是很奇怪,因为它不需要花很长的时间来解释它?
I am developing classified ads application in ASP.NET MVC3 using Entity Framework 4.3 for database.
I am facing problem when user session is active and execute any database query by entity framework then application session time's out unexpectedly.
Note that the query gets execute successfully and I can see my results as well but after a little while asp.net session terminates.
This only happen when I host my application to the live server (Arvixe). On my Local IIS it is working fine.
If I use any other source for database query then it is working fine.
I have also reset session time-out in web.config. I am using MYSQL. Any thoughts?
I am using this simple login method and it is working fine..
using (Html.BeginForm("ValidateLogin", "User", FormMethod.Post))
{
<div>
<input type="text" name="LoginName" id="LoginName" />
<input type="password" name="Password" id="Password" />
<p>
<input type="checkbox" name="RememberMe" /><span>Remember me?</span></p>
<input id="Submit1" type="submit" value="submit" />
</div>
}
[HttpPost]
public ActionResult ValidateLogin(string LoginName, string Password, string RememberMe)
{
User aUser = new User(); //User Class
var userList= db.Users.Where(u => (u.Loginname.ToLower() == name.ToLower() || u.Email == name) && u.Password == password);
if (Users.Count() > 0)
{
aUser = Users.Take(1).Single();
Session.Add("user",aUser.UserId);
return RedirectToAction("Index", "Home");
}
else
{
return RedirectToAction("Login", "User", new { error = "login" });
}
Have you set a really long timeout ? Is it timing out, or is it weird BECAUSE it doesn't take long enough to explain it ?
这篇关于ASP.NET MVC实体框架4.3中数据库调用的会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!