- MVC 4 웹 응용 프로그램이 있습니다.
- iis7 환경에 배포되었습니다.
- Windows 인증 및 가장을 사용합니다.
- 회사 정책에 따라 15 분 후에 세션 제한 시간으로 설정됩니다.
이 항상 asp.net 응용 프로그램에서 잘 작동. 하지만 이제는 MVC4 응용 프로그램을 가지고 있으므로 global.asax와 session_start를 사용하여 세션 시간이 초과되었는지 다시 결정하는지 확인하는 대신 세션 만료 작업 필터를 설정했습니다.유휴 시간 초과 후 MVC4 응용 프로그램의 세션 시간 초과 처리기에서 무한 루프 문제가 발생합니다.
사용자가 응용 프로그램을 유휴 상태로 둘 때까지 모두 세션 시간 초과가 예상대로 작동합니다. 응용 프로그램 풀의 유휴 시간 제한은 20 분입니다.
내 사용자가 자신의 응용 프로그램을 열어두고 자주하는 회의에 참석하고 유휴 시간 제한에 도달 한 경우 다시 돌아와서 시도 할 때 응용 프로그램이 세션 시간 초과시 재 지정을 시도하면 오류 로그에서 루프에 갇히게되고 결코 재 지정되지 않습니다.
리디렉션을 시도하기에는 사실 (유휴 시간 초과)이 너무 늦습니까? 이전 asp.net 응용 프로그램 (비 MVC)에서 나는이 작업 (예 : 세션 시간 초과시 리디렉션)을 global.asax의 세션 시작에서 항상 수행하는 데 사용 했었습니다. obviosuly,이 이벤트는 항상 걷어 응용 프로그램 유휴 시간 초과하기 전에 맞았
어떤 도움을 주시면 감사하겠습니다, 여기 내 세션 핸들러 내 코드입니다. 경우 사람에
public class SessionExpireAttribute : ActionFilterAttribute
{
/// <summary>
/// Called by the ASP.NET MVC framework after the action method executes.
/// </summary>
/// <param name="filterContext">The filter context.</param>
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
base.OnActionExecuted(filterContext);
}
///<summary>
///Called by the ASP.NET MVC framework before the action method executes.
///</summary>
///<param name="filterContext">The filter context.</param>
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext.HttpContext.Session != null)
{
if (filterContext.HttpContext.Session.IsNewSession)
{
var sessionStateDetails =(SessionStateSection)ConfigurationManager.GetSection("system.web/sessionState");
var sessionCookie = filterContext.HttpContext.Request.Headers["Cookie"];
if ((sessionCookie != null) && (sessionCookie.IndexOf(sessionStateDetails.CookieName) >= 0))
{
if (filterContext.HttpContext.Request.IsAjaxRequest())
{
filterContext.HttpContext.Response.Clear();
filterContext.HttpContext.Response.StatusCode = 403;
}
else
{
RouteValueDictionary redirectTargetDictionary = new RouteValueDictionary();
redirectTargetDictionary.Add("action", "SessionTimeout");
redirectTargetDictionary.Add("controller", "Home");
filterContext.Result = new RedirectToRouteResult(redirectTargetDictionary);
}
MVC에서도 Session_Start를 사용할 수 있습니다. 왜 그런가요? –
예 session_start는 MVC4에서 여전히 작동하고 올바르게 리디렉션됩니다. 그러나 블로그에서 읽은 적이 있는데, 나는 처리기를 사용하는 것이 더 나은 방법이라고 생각 했습니까? 이견있는 사람 ? 그리고 이것이 제가이 길로 내려간 이유입니다. – Alicia