Uygar Kılıç

Uygar Kılıç

  • 1.9k
  • 24
  • 139

Too many redirects error in MVC application

Jun 2 2021 11:56 AM
I am getting Too many redirects error in my MVC application.
 
After i add UserFilter : ActionFilterAttribute how can i solve this problem ?
  1. public class UserFilter : ActionFilterAttribute  
  2. {  
  3. public override void OnActionExecuting(ActionExecutingContext context)  
  4. {  
  5. int? userid = context.HttpContext.Session.GetInt32("id");  
  6. if (!userid.HasValue)  
  7. {  
  8. context.Result = new RedirectToRouteResult(  
  9. new RouteValueDictionary  
  10. {  
  11. {"action","Index"},  
  12. {"controller","Admin"}  
  13. }  
  14. );  
  15. }  
  16. }  
  17. }  

Answers (10)