Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9127799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:22:03+00:00 2026-06-17T07:22:03+00:00

When i post a DateTime with Json i have the following error: Error 500

  • 0

When i post a DateTime with Json i have the following error:
Error 500 Can’t cast object of type “System.DateTime” to type “System.Array”.

I don’t understant why !
Can you help me please ?

the header send look like this :

{"MyDate":"2012-12-31T23:00:00.000Z","Param1":"aaaa","IdItem":123}

My viewModel :

 public class MyViewModel
 {
public DateTime MyDate { get; set; }
public string Param1 {get;set;}
public Int32? IdItem { get; set; }
 }

My controller :

[HttpPost]
    public void Saisie(MyViewModel model)
    { ... }

My Javascript code :

$.ajax({
        url: url,
        type: 'post',
        dataType: 'json',
        data : JSON.stringify(model),
        contentType: 'application/json',
success : function() {...}
})
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:22:05+00:00Added an answer on June 17, 2026 at 7:22 am

    I have found my problem, in the view model i have :

    public class MyViewModel
    {
    [MaxLength(10)]
    public DateTime MyDate { get; set; }
    }
    

    the MaxLength attribut cause the error

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I post(using jQuery $.post) the following json DateTime to a WCF service(using C#): /Date(1331713200000)/
I have an Action Method that returns a JSON-serialized object. The problem I'm having
When I post a json object with a date property to a ApiController it
I have a Winform client that sends a json post request to my controller
I have WCF with contract like that [WebInvoke(Method = POST, ResponseFormat = WebMessageFormat.Json, RequestFormat
I have in my view Datetime fied like these @Html.EditorFor(m => m.StartDate) <input type=button
I have a post model with a datetime field called published_at. On my form
I have a spring MVC java application and I'm serializing joda DateTime to json.
POST /api/crmteetimeapi.asmx/Login HTTP/1.1 Host: golffacility.com Content-Type: application/x-www-form-urlencoded Content-Length: length OwnerID=string&UserID=string&Password=string What language do I
Post-release, I have made one small change to one form in our development site

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.