title: Passing a DateTime parameter to ASP.NET Web Service
body: <p>Is it possible to post a DateTime parameter to a Web Method inside an ASMX web service (using a JSON serialized RPC style call)?</p>
  
  <p>I am sending a DateTime to the browser and this gets serialized in the form /Date(1350639464100+0100)/. I can then use the excellent <a href="http://momentjs.com/" rel="nofollow">moment.js</a> library to parse the date, display it on the page etc.</p>
  
  <p>My problem is returning this date to the server using an AJAX post to my web service. My web method looks something like this:</p>
  
  <pre><code>[WebMethod(EnableSession = true)]
  [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  public void Save(DateTime date)
  {
      // Do stuff
  }
  </code></pre>
  
  <p>If I try to send a date in the same format as it came down (/Date(1350639464100+0100)/) then I get an error: </p>
  
  <p><strong>/Date(1350639464100+0100)/ is not a valid value for DateTime.</strong></p>
  
  <p>Are there any better alternatives to sending this up as a string and then parsing the value on the server? Ideally I'd like to be able to send objects on a round trip to and from the server without having to alter any date properties that they may contain.</p>
  
  <p>Thanks for any help!</p>