0

I am using a custom authorize attribute in my MVC 4 web site which acts as a global action filter. Code is pretty pretty simple like below:

 public class CustomAuthorizeAttribute : AuthorizeAttribute
    {
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            var user = Membership.GetUser(filterContext.HttpContext.User.Identity.Name, true);

            if (!filterContext.HttpContext.User.Identity.IsAuthenticated || user == null || !user.IsApproved || user.IsLockedOut|| !System.Web.Security.Roles.GetRolesForUser().Any() )
            {
                HandleUnauthorizedRequest(filterContext);
            }
            base.OnAuthorization(filterContext);
        }
} 

This works absolutely fine but in one of the action methods in my application which is called by $.getJSON request filterContext.HttpContext.User property is getting null. I am sending a concatenated string in the data parameter with my getJson request, if the length of this string is large then only I'm facing this issue otherwise I never receive null User. Any help will be really appreciated.

binu
  • 337
  • 2
  • 5
  • 16
  • 1
    This is probably a setting on your server. There is typically a maximum response size. Have you looked in Firebug to see if the response is actually getting to the browser? –  Jul 04 '14 at 10:33
  • just check instead of $.getJson() use $.post() becoz $.getJson() gives problem for larger data string... –  Jul 04 '14 at 10:36
  • @KartikeyaKhosla, [No it doesn't](http://stackoverflow.com/questions/2915366/getjson-not-working-for-large-data). getJson is just a wrapper for ajax. The same code is executed underneath – Liam Jul 04 '14 at 10:49
  • use post the required code here... –  Jul 04 '14 at 10:51
  • Hi Kartikeya, request is going to server in a get request but on the server as my CustomAthorizeAttribute executes at the very begining where I get the error I am unable to check what is happening with the Json data on the server. How to check it on the server any idea? – binu Jul 04 '14 at 10:52
  • just show here where do you applied custom athorize attribute in ur controller???? –  Jul 04 '14 at 11:04
  • [HttpGet] [CustomAuthorize(Roles = "Investigator,Supervisor,Manager,Viewer")] [OutputCache(CacheProfile = "Cache1Minute", VaryByParam = "EventPage;FromDateTime;ToDateTime;SiteId;TagName")] public JsonResult GetEventsGrid(OperationalStatusParamViewModel paramModel) – binu Jul 04 '14 at 12:07
  • Json call is like this $.getJSON(window.appRoot + "OperationalStatus/GetEventsGrid", paramData, function (d) {------} – binu Jul 04 '14 at 12:09

0 Answers0