Note that there are some explanatory texts on larger screens.

plurals
  1. POPOST not accepting int parameter
    primarykey
    data
    text
    <p>I have a problem with ASP.NET MVC3.</p> <p>I'm trying to post some parameters to a JSONResult action. It works great when i use GET, but when i use POST, i get an error, because apparently when using POST, it won't accept my integer parameters as such, and say that the parameters dictionary contains a null value for them.</p> <p>Anyone run across this before? Thanks.</p> <p>Edit: some code, as requested:</p> <pre><code>public JSONResult PostingHere(string username, int someotherparameter) { //Code } </code></pre> <p>Really, that's all that matters, because the exception is thrown then and there when POSTing because apparantly a null value gets passed to the <code>someotherparameter</code> parameter. When using GET, as said before, it works just dandy.</p> <p>The intended use is to post with a NSURLRequest from an iPhone, but I've been debugging with a firefox extension called <em>Poster</em> and i get the same result. Full error: </p> <p><em>The parameters dictionary contains a null entry for parameter 'someotherparameter' of non-nullable type 'System.Int16' for method 'System.Web.Mvc.JsonResult PostingHere(System.String, Int16)'</em></p> <p>Edit 2: By request, I'll add an example of calling the action which results in the error:</p> <pre><code>&lt;form action="http://fullurlhere.com/Controller/PostingHere" method="POST"&gt; &lt;input type="hidden" name="userid" value="astring" /&gt; &lt;input type="hidden" name="someotherparameter" value="100" /&gt; &lt;input type="submit" value="Brace for impact" /&gt; &lt;/form&gt; </code></pre> <p>Edit 3: The post data; never mind the discrepancy in variable names, these are the actual names of them.</p> <p><img src="https://i.stack.imgur.com/uhZVb.jpg" alt="Result of the Post"></p> <p>Edit 4: Adding to the mystery, the problem disappears when testing against a local server on my own computer, with the very same MVC Project the server is running. So the problem is likely within a server-side setting.</p> <p>Solved: Turns out when i evalutated the request, that the server was redirecting me to https:// from the http://, causing me to lose my POSTed data. Thanks to everyone for being such good sports.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload