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
Karan Thakkar
1.5k
204
89.5k
How will I set time for session timeout in form authention?
Mar 26 2019 2:13 AM
I want to set session 1 minute in form authentication in asp.net MVC
below is my code I tried several ways but I failed to do so.
webconfig code:
<
system.web
>
<
authentication
mode
=
"Forms"
>
<
forms
loginUrl
=
"~/Authentication/Login"
>
</
forms
>
</
authentication
>
</
system.web
>
custom filtration class
public
override
void
OnActionExecuting(ActionExecutingContext filterContext)
{
if
(HttpContext.Current.Session[
"UserInfo"
] ==
null
)
{
bool
skipImportantTaskFilter = filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(
typeof
(SkipImportantTaskAttribute),
true
) || filterContext.ActionDescriptor.IsDefined(
typeof
(SkipImportantTaskAttribute),
true
);
if
(skipImportantTaskFilter ==
false
)
{
filterContext.Result =
new
RedirectResult(
"~/Login/Index"
);
FormsAuthentication.SignOut();
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
HttpContext.Current.Response.Cache.SetNoStore();
HttpContext.Current.Session.Abandon();
HttpContext.Current.Response.Write(
"<script language='javascript'>"
);
HttpContext.Current.Response.Write(
"function ClearHistory()"
);
HttpContext.Current.Response.Write(
"{"
);
HttpContext.Current.Response.Write(
" var backlen=history.length;"
);
HttpContext.Current.Response.Write(
" history.go(-backlen);"
);
HttpContext.Current.Response.Write(
"}"
);
HttpContext.Current.Response.Write(
"</script>"
);
return
;
}
}
else
{
User user = (User)HttpContext.Current.Session[
"UserInfo"
];
if
(user.ForcePwdChange && filterContext.ActionDescriptor.ActionName !=
"CallChangePassword"
&& filterContext.ActionDescriptor.ActionName !=
"ChangePassword"
)
{
filterContext.Result =
new
RedirectResult(
"~/Login/CallChangePassword"
);
return
;
}
}
}
Reply
Answers (
1
)
Salary expectation for DOT net 5.5 year Expr in .net,C#,MVC5
:: BarCode Scanner and specify hidden field ::