TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Arif Hussain
NA
17
4.1k
How to increase Session timeout in C# MVC web application?
Jan 20 2021 9:41 AM
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();
}
}
Reply
Answers (
8
)
asp.net core split a string in two strings
pass value from view to controller