Hi,
I am developing an web application in c# MVC, I am facing an issue in login session time. After few minutes login when I refresh the page or go to another page, it will logout and redirect to login page. I also set the "timeout="1440" in web.config file. Kindly go through following code.
WEB.CONFIG
- <system.web>
- <compilation targetFramework="4.5" tempDirectory="C:\Inetpub\vhosts\webdealsinv.com\tmp" />
- <httpRuntime targetFramework="4.5" />
- <authentication mode="Forms">
- <forms loginUrl="Home/Login" timeout="1440" slidingExpiration="true" />
- </authentication>
- <roleManager enabled="true" defaultProvider="InvRoleProvider" cookieTimeout="1440">
- <providers>
- <clear />
- <add name="InvRoleProvider" type="Inventory.Helper.InvRoleProvider" />
- </providers>
- </roleManager>
- <httpHandlers>
- <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
- <add verb="GET" path="routejs.axd" type="RouteJs.RouteJsHandler, RouteJs" />
- </httpHandlers>
- <membership userIsOnlineTimeWindow="1440" />
- <sessionState mode="InProc" timeout="1440" cookieless="false" />
- </system.web>
LOGIN ACTION
- [HttpPost, AllowAnonymous]
- public ActionResult Login(InvUser invuser)
- {
- string result = objData.CheckUser(invuser);
- if (result == "Success")
- {
- InvUser _invuser = objData.GetUser(invuser);
- FormsAuthentication.SetAuthCookie(_invuser.UserID.ToString() + "|" + _invuser.FirstName, true);
- return RedirectToAction("Index", "Admin");
- }
- else
- {
- ViewBag.Msg = "Invalid Email or password!";
- return View();
- }
- }