HTML form data lost in POST

We have a very strange problem that we still cannot diagnose. Our application has a number of specific ASP.NET MVC actions that fail due to the lack of the required parameter:

The parameters dictionary contains a null entry for parameter 'myVariable' of non-nullable type... etc 

Each of them is a kind of HTTP POST, and therefore we expect to see the form data. In some cases, there must be more than a dozen variables.

We use ELMAH to collect errors in a web application, and with this tool you can usually see the actual form data that is published during a request that fails. However, in these specific errprs, when there should be several variables, the whole form is missing!

We simply cannot reproduce this on demand. However, with the amount of traffic in our application, we see these errors several dozen times a day. Users also cannot reproduce the error, and the repetition of the same action in the web browser is performed a second time.

We are also not 100% sure where the data is lost. Is it in a web browser? Inside the IIS pipeline? Or is it an ASP.NET MVC that resets it? Totally unsure.

If someone can help us fix the problem and / or diagnose this problem, we will be very grateful.

Update 1: We found that the length of the content indicated in the HTTP headers is of a size that assumes that there is some content in the request. However, the collection of forms on request is empty (according to ELMAH). Therefore, we have added several additional protocols to track the actual length of the received content and the content itself.

Update 2: We found that although the CONTENT_LENGTH HTTP header is the correct size (for similar requests), the content itself is missing. The stream contains 0 bytes.

We can also narrow down the problem to Internet Explorer, we cannot make it work with other browsers.

We could sometimes recreate the problem by invoking multiple overlapping AJAX requests in the browser, and then either updating or redirecting. It is almost as if Internet Explorer closes the connection before writing the stream buffer completely.

We were unable to trace this with Fiddler. Using Fiddler, it seems that it is impossible to recreate a specific situation.

Update 3: Everything we saw can be explained as follows: Why doesn't Internet Explorer send the body of an HTTP message after an Ajax call after a failure?

+4
source share
3 answers

The source of the problem can be explained by the following: Why does Internet Explorer not send the body of an HTTP message after an Ajax call after a failure?

Update. Turns out our specific symptoms seemed to be related to using jQuery. After the update, the problem eventually disappeared.

0
source

This may be a little guess, but is it possible that your action does not have a [HttpPost] restriction on it, so that somehow users will receive it via GET, not POST?

I had something similar in my application where users tried to send POST to the URL, but their ticket for FormsAuthentication expired, so they are redirected to the login page. But since the "ReturnUrl" parameter is passed on the login page, after they are logged in, they are redirected back to the page from which they are intended for POSTing, but this time with GET. This will cause the error you described, since obviously no POST data is present. As I said, a little guess ...

+1
source

The error message you provided does not seem to be something wrong in the form. For me, this seems like a routing problem, so I would like to ask:

  • Is POST running the correct controller / action? For example, check that it moves to the correct area (if you use it).
  • Is the signature of the controller action method signed, especially the myVariable parameter, in accordance with the route pattern? In other words, its possible your action expects myVariable, but the Url calling it either does not have "myVariable" or has a spelling error, etc.
0
source

All Articles