I have an MVC5 application that throws a NullReferenceException on the production server when using the attribute [Authorize]on the controller. The application uses forms-based authentication.
The production server is Server 2008 SP 2 (.NET 4.5.1 and IIS 7).
Start stack trace:
[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.Mvc.AuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) +38
System.Web.Mvc.AuthorizeAttribute.OnAuthorization(AuthorizationContext filterContext) +293
System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor) +155
I can fix this by setting
<modules runAllManagedModulesForAllRequests="true">
However, I prefer not to use this sledgehammer method .
Is there a cleaner way to solve this problem?
source
share