views:

63

answers:

1

I have an ASP.NET MVC 2 application (.NET 4) that takes an HTTP post with two parameters. The second parameter is a big chunk of html. The controller action is shown below.

    [ValidateInput(false)]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult TriangleUpdate(string userId, string html)
    {

        var user = _udRep.GetUserInfoForUser(userId);
        if (user == null)
        {
            return Json(new { Result = "INVALID_USER" });
        }

        System.Diagnostics.Debug.Write(html);
        if (!EnsureValidTriangleHTML(html))
        {
            return Json(new { Result = "INVALID_HTML" });
        }

        //other code here
     }

When the html that is posted to this method is fairly large, approx 300 KB, the content of the html parameter is truncated. The System.Diagnostics.Debug.Write(html) only outputs some of the content input that is passed in.

Fiddler shows full 'application/x-www-form-urlencoded' post going out with a "Content-Length: 366050" header. However on server side, only some of the content is available in the html parameter.

Is there some kind of buffer not being flushed or maximum content limit to HTTP posts?

A: 

I am going to answer my own question on this. The html that was returned was generated by a system outside of my control. There was an   element in the html that was breaking the form values to an additional field. That was what was truncating the html.

In order to troubleshoot this, I had to create a custom model binder to examine the HttpContext's Request.Form collection. Instead of having 2 elements in the NameValueCollection there was 3 and that led me to find the problem.

Hope this helps some one else trying to troubleshoot a similar issue.

Mike Weerasinghe