Server cannot set status after HTTP headers have been sent IIS7.5

后端 未结 10 923
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 12:32

Sometimes I get exception in my production environment:

  • Process information
    • Process ID: 3832
    • Pr
10条回答
  •  情歌与酒
    2020-11-27 13:00

    İf someone still having this problem.Try to use instead of ovverriding

     public void OnActionExecuting(ActionExecutingContext context)
        {
            try
            {
    
                if (!HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (!HttpContext.Current.Response.IsRequestBeingRedirected)
                    {
    
                        context.Result = new RedirectToRouteResult(
                    new RouteValueDictionary {  { "controller", "Login" }, { "action", "Index" } });
                    }
                }
    
            }
            catch (Exception ex)
            {
                   new RouteValueDictionary { { "controller", "Login" }, { "action", "Index" } });
            }
    
        }
    

提交回复
热议问题