I have an asp.net mvc web app that has controllers with role attributes on them for checking authenticated user roles. I ran into a problem with ajax where I have ajax “get” requests that trigger additional role and user checks each time a page is loaded up.
Right now when I load up one of my pages I have the same query running 4 times because of the ajax requests hitting the roles attributes on the controller. Does anyone know any good techniques to prevent this from happening?
Thanks
How about creating a custom attribute extending asp.net mvc´s
AuthorizeAttributeand checking in your implementation if the request is an Ajax request or not?Request.IsAjaxRequestYou can use the base behaviour if the request is not an ajax request, otherwise return
Regards.