I am working on a ASP.NET MVC application. There are partial views, a controller, handler and a model that is iterated and its items are displayed on view. It works fine, until I get more than 25 elements in my list. If I return 26 elements it starts showing a "The connection was reset" message in the browsers(FF and Chrome):
These are the partial views:
Iterating model items:
@foreach(ingredientsListItemModel ingredientsListItem in Model.ingredientsListItems)
{
<text>
<div id="@ingredientsListItem.ContainerDiv">
@Html.Partial("Partial/ingredientsListItem", ingredientsListItem)
</div>
</text>
}
Showing each item as a container:
@using (Ajax.BuildForm("AddElement", "Item", Model.FormId, new AjaxOptions { UpdateTargetId = Model.ContainerDiv }))
{
<div id="ingredientsListitem" class="yui3-g ingredientsListitem">
<div class="yui3-u-1-3">
<a href="@url">
<img src="@Model.ImageUrl" alt="" />
</a>
</div>
<div class="yui3-u-2-3">
<div class="itemdescription">
<a href="@url">
@MvcHtmlString.Create(Model.ItemDescription)
</a>
</div>
</div>
</div>
@Html.HiddenFor(m => m.ingredientsListId);
}
These are the controller methods to have an idea of the data:
Controller:
public ActionResult GetingredientsList()
{
if (Request.IsAjaxRequest())
{
return PartialView("Partial/ingredientsList", Handler.GetingredientsListModel(MvcApplication.ClientApplication));
}
Handler:
private static IEnumerable<ingredientsListItemModel> GetingredientsListItems(ClientApplication clientApplication)
{
//Some code...
return list.ToList();
//if this list contains more than 25 elements it starts failing and showing the Connection reset error.
}
I tried changing the web.config to include (but it didn't work):
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
No matter which element is in the list, it can be any data but once it is bigger than 25 items, it fails. I am thinking there could be a response size limit to be changed in some way? in IIS? in web.config? It seems it is a size limit problem. Well, any help will be very appreciated.