Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC: Default model binder not working on Safari (but does work for Firefox)
    primarykey
    data
    text
    <p>Very strange issue... I have something like this in my Controller:</p> <pre><code>public ActionResult Initialize(IEnumerable&lt;MyModel&gt; Requests) { ... } </code></pre> <p>I generate form elements in my submitting View that look like this:</p> <pre><code>Requests[90ed54f6-4650-44c7-8cc2-c4d225a9a334].Name Requests[90ed54f6-4650-44c7-8cc2-c4d225a9a334].Address Requests[db67e8e5-94f8-4b35-b69c-65184980f2a1].Name Requests[db67e8e5-94f8-4b35-b69c-65184980f2a1].Address </code></pre> <p>On Firefox, when I submit this with multiple elements, the binder works and I get a collection of objects. On Safari, the exact same data always generates only 1 object in the collection.</p> <p>Weirdly, in the debugger if I look at Requests.Params.AllKeys[] I see the values -- they're being submitted, just somehow not binding. I use Firebug on Firefox but don't have an equivalent tool for Safari. Since I see the values in the Request.Params, I assume that it's not an issue with the form values being passed in -- just something about they way they're being bound to the ViewModel...</p> <p>The binder is kind of black magic to me -- I'm not sure where this lives and if I can step through this to see what it's doing.</p> <p>Any ideas what this might be or how I might chase this down?</p> <p><strong>Edit:</strong> This works correctly in IE as well -- just Safari is acting weird.</p> <p><strong>Edit 2:</strong> I lied... Safari does not post the index values as I would expect:</p> <pre><code>Requests.index = {GUID} Requests[90ed54f6-4650-44c7-8cc2-c4d225a9a334].Name Requests[90ed54f6-4650-44c7-8cc2-c4d225a9a334].Address Requests.index = {GUID} Requests[db67e8e5-94f8-4b35-b69c-65184980f2a1].Name Requests[db67e8e5-94f8-4b35-b69c-65184980f2a1].Address </code></pre> <p>Both Firefox and Internet Explorer post both <code>Requests.index</code> values as comma separated values, but Safari only posts the first. I'm not sure what "correct" is for this case, but this is something I can sink my teeth into.</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.
 

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