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
Guest User
Tech Writer
515
47k
About keeping session alive in mvc
Nov 19 2020 12:36 PM
hello,
Hope everyone is doing fine
I want to redirect to logout page after session is null or expired.
I am able to do it with Global.asax file with following code :
I have created
Session["LoginCheckSession"]
while login or after signup.
public class SessionTimeoutAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
HttpContext ctx = HttpContext.Current;
if (HttpContext.Current.Session["LoginCheckSession"] == null)
{
filterContext.Result = new RedirectResult("~/Home/Index");
return;
}
base.OnActionExecuting(filterContext);
}
}
But I have TWO different sessions for two different Login pages, one for Admin and Other for User
With the above code, I can only redirect to either Admin or User Login page
So is there any way I can use two different sessions on global.asax file and then redirect to a different login page
Or anyway I can keep the session alive for a long time
thank you in advance
Reply
Answers (
12
)
Cognito and ASP.NET C# problem
Validation message and Validation summary tag helper in MVC 5.0