FBryant87
FBryant87

Reputation: 4595

MVC - "This page can’t be displayed" - IE only with no exception

In my controller Index() method I retrieve some data from the DB, before returning the contents to the view:

    [HttpGet]
    public ViewResult Index()
    {
        var model = new ItemsModel();

        model.Items = itemService.GetSomeItems(User.RoleId);

        return View(model);
    }

This always works flawlessly on Chrome and Firefox, but IE 11 only works depending on what is returned by the GetSomeItems method.

When there aren't many items to get, IE returns the view no problem. But if there are, for example, 300 items returned (call takes about 4 seconds), IE waits for about 5-8 seconds before showing "This page can’t be displayed" page.

The results vary based on what is returned in the service method - though I'm not sure if it's the volume of items, their contents, or the call time.

When I debug the application it runs flawlessly with no exception, just ending up on the "This page can’t be displayed" page. It's not my cache causing the problem because other users experience the exact same issue with IE only. I've tried placing debug points in the jquery $(document).ready method of Index.cshtml, but these are never reached.

What is it about IE which could be causing this? I know there are in-built timeouts (browser timeouts while asp.net application keeps running), but a call taking 4 seconds does not explain the above. Any ideas? The accessor behind the call makes use of Entity Framework, if that might be a culprit. Tested for other IE versions using F12 and this fails for IE 11,10,9 also.

Upvotes: 1

Views: 622

Answers (1)

FBryant87
FBryant87

Reputation: 4595

The issue was caused by IE collapsing when too many AntiForgeryTokens are included on a page.

When GetSomeItems() returned more than 236 objects, these were looped over in the view and resulted in ~240 @Html.AntiForgeryToken() lines - which IE is unable to cope with.

Upvotes: 1

Related Questions