title: MVC 4 - JQuery/Ajax post returns [ArgumentException: Invalid JSON primitive: Category.]
body: <p>I'm trying to post a form to a specific Action in MVC 4 using ajax. It enters the controller/action, but it throws a NullReferenceException, eventhough the Action does receive the data.</p>
  
  <p>Here is the action:</p>
  
  <pre><code>    [HttpPost]
      public ActionResult EditPlayer(PlayerDisplay myPlayer)
      {    
  
              updatePlayer(myPlayer); //updatePlayer() does all the work of updating the player information.
              bool json = true;
              return Json(json);
      }
  </code></pre>
  
  <p>Here is the form </p>
  
  <p>@model WebPlayerMonitor.Models.PlayerDisplay</p>
  
  <pre><code>&lt;fieldset&gt;
      &lt;legend id="edit-player-account"&gt;&lt;b&gt;Account: &lt;/b&gt;@Model.account&lt;/legend&gt;
      &lt;form id="editForm"&gt;
  ...
      &lt;button id="btn-edit" class="button round medium"&gt;Save &amp; Close&lt;/button&gt;
      &lt;a class="close-reveal-modal"&gt;&amp;#215;&lt;/a&gt;
  &lt;/form&gt;
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>Here is the Ajax:</p>
  
  <pre><code>$("#btn-edit").click(function () {
   var myPlayer = $("#editForm").serialize();
      $.ajax({
          url: "/playermonitor/PlayerMonitor/EditPlayer",
          type: "Post",
          contentType: "application/json",
          data: myPlayer,
  
          success: function (message) {
              $('#playermodal').foundation('reveal', 'close');
          },
          error: function (message) {
          }
      })
  })
  </code></pre>
  
  <p>The Model:</p>
  
  <pre><code>    public class PlayerDisplay
      {
          [StringLength(maximumLength: 30)]
          [Required]
          [Display(Name = "Account")]
          public string account { get; set; }
  
          [DataType(DataType.Text)]
          [StringLength(maximumLength: 255)]
          [Display(Name = "Link Iovation")]
          public string link_Iovation { get; set; }
  
          [Display(Name = "Deposit Type")]
          public string Deposittype { get; set; }
  
          [Display(Name = "8-Ball %")]
          public float? eight_Ball { get; set; }
  
          [DataType(DataType.Text)]
          [StringLength(maximumLength: 50)]
          [Display(Name = "Location")]
          public string location { get; set; }
  
          [Display(Name = "Lifetime")]
          public float? lifetime { get; set; }
  
          [Display(Name = "Master")]
          public bool master { get; set; }
  
          [DataType(DataType.Text)]
          [StringLength(maximumLength: 50)]
          public string Agent { get; set; }
  
          [Display(Name = "B-Line")]
          public bool b_line { get; set; }
  
          [DataType(DataType.MultilineText)]
          [StringLength(maximumLength: 1020)]
          [Display(Name = "Notes")]
          public string notes { get; set; }
  
          [Required]
          public string Status { get; set; }
  
          [Required]
  
          public string Category { get; set; }
  
          [Display(Name = "Submitted")]
          public DateTime? date { get; set; }
  
          public string Office { get; set; }
  
          [Display(Name = "Submitted By")]
          public string User { get; set; }
  
          [Display(Name = "Last Updated By")]
          public string User_LastUp { get; set; }
  
          [DataType(DataType.MultilineText)]
          [StringLength(maximumLength: 200)]
          [Required]
          [Display(Name = "Submit Notes")]
          public string shortNotes { get; set; }
  
          [RegularExpression(@"\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b",
              ErrorMessage = "Enter a valid IP format.")]
          [Display(Name = "IP Address")]
          public string ip_Address { get; set; }
  
          public bool? state { get; set; }
  
          [Display(Name = "Monitor Date")]
          public DateTime? monitorDate { get; set; }
  
          [Display(Name = "RFCheck Date")]
          public DateTime? RFCheckDate { get; set; }
  
          public string categoryMultiple { get; set; }
  
          public PlayerDisplay()
          {
          }
      }
  </code></pre>
  
  <p>The Headers Info from Chrome Developer Tools:</p>
  
  <pre><code>Remote Address:xx.0.222.114:48
  Request URL:http://crislife.im.priv:48/playermonitor/PlayerMonitor/EditPlayer
  Request Method:POST
  Status Code:500 Internal Server Error
  Request Headersview source
  Accept:*/*
  Accept-Encoding:gzip,deflate
  Accept-Language:en-US,en;q=0.8,es;q=0.6
  Connection:keep-alive
  Content-Length:599
  Content-Type:application/json
  Cookie:ASP.NET_SessionId=h40g5ar5yhrfgfsv4re1l0a1
  Host:crislife.im.priv:48
  Origin:http://crislife.im.priv:48
  Referer:http://crislife.im.priv:48/playermonitor/
  User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36
  X-Requested-With:XMLHttpRequest
  Request Payload
  Category=8Ball+Edge&amp;Status=Ready+for+Check&amp;Deposittype=Money+Bookers&amp;Office=BETCRIS+INT+BKR&amp;Agent=my+agentsssd&amp;master=true&amp;link_Iovation=soelinkssssss&amp;eight_Ball=1&amp;location=earthssssss&amp;lifetime=2&amp;ip_Address=123.123.123.125&amp;b_line=true&amp;notes=awesome+new+notesssssss5s&amp;account=NEWAWESOME&amp;state=True&amp;monitorDate=9%2F24%2F2014+3%3A50%3A12+PM&amp;shortNotes=quick%2Fnew+notes%2Fsome+more+notes%2Fandmorenotes%2Fjl%3Bjkl%3Bjasdf%2Fadding+to+it&amp;RFCheckDate=9%2F24%2F2014+3%3A50%3A12+PM&amp;date=9%2F22%2F2014+9%3A33%3A01+AM&amp;User=ADEN&amp;User_LastUp=ADEN&amp;categoryMultiple=8Ball+Edge%2CFraud+Check%2CNew+Deposit%2CSharp
  Response Headersview source
  Cache-Control:private
  Content-Length:11536
  Content-Type:text/html; charset=utf-8
  Date:Mon, 20 Oct 2014 21:45:43 GMT
  Server:Microsoft-IIS/7.5
  X-AspNet-Version:4.0.30319
  X-Powered-By:ASP.NET
  </code></pre>
  
  <p>And the error I'm getting:</p>
  
  <pre><code> [ArgumentException: Invalid JSON primitive: Category.]   
  System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() +745   
  System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +362   
  System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) +115   
  System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) +49   
  System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(ControllerContext controllerContext) +242   
  System.Web.Mvc.&lt;&gt;c__DisplayClassc.&lt;GetValueProvider&gt;b__7(ValueProviderFactory factory) +28   
  System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +248   
  System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +165   
  System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +536   
  System.Linq.Enumerable.ToList(IEnumerable`1 source) +80   
  System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) +347   
  System.Web.Mvc.ControllerBase.get_ValueProvider() +66   
  System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +81   
  System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +153   
  System.Web.Mvc.Async.&lt;&gt;c__DisplayClass25.&lt;BeginInvokeAction&gt;b__1e(AsyncCallback asyncCallback, Object asyncState) +955  
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146   
  System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +166   
  System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag) +27   
  System.Web.Mvc.&lt;&gt;c__DisplayClass1d.&lt;BeginExecuteCore&gt;b__17(AsyncCallback asyncCallback, Object asyncState) +50   
  System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146   
  System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +166   
  System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +497   
  System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146   
  System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +166   
  System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag) +27   
  System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +409   
  System.Web.Mvc.&lt;&gt;c__DisplayClass8.&lt;BeginProcessRequest&gt;b__2(AsyncCallback asyncCallback, Object asyncState) +144   
  System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146   
  System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +166   
  System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag) +27   
  System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +364   
  System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12650919   
  System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +288
  </code></pre>
  
  <p>This ONLY happens when I publish it to the website. When I run it on debug mode, everything runs properly. Also, I have other ajax posts that are exactly the same, and those work no problem.
  When I remove  contentType: "application/json" and dataType: 'json', I get a null reference exception. I've checked many times and it is capturing all the fields from the form.</p>