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

  • SEARCH
  • Home
  • 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 6707923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:41:50+00:00 2026-05-26T07:41:50+00:00

We know that MVC returns DateTime for JsonResult in this format: /Date(1240718400000)/ , and

  • 0

We know that MVC returns DateTime for JsonResult in this format: /Date(1240718400000)/, and we know how to parse it in JS.

However, It seems that MVC doesn’t accept DateTime parameter being sent in this way. For example, I have the following Action.

[HttpGet]
public ViewResult Detail(BookDetail details) { //... }

The BookDetail class contains a DateTime field named CreateDate, and I passed a JSON object from JS in this format:

{"CreateDate": "/Date(1319144453250)/"}

CreateDate is recognized as null.

If I passed the JSON in this way, it works as expected:

{"CreateDate": "2011-10-10"}

The problem is that I cannot change client side code in an easy way, have to stick to /Date(1319144453250)/ this format. I have to make changes in server side.

How to solve this problem? Is that anything related to ModelBinder?

Thanks so much in advance!

  • 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-05-26T07:41:50+00:00Added an answer on May 26, 2026 at 7:41 am

    The problem, as you suspected, is a model binding issue.

    To work around it, create a custom type, and let’s call it JsonDateTime. Because DateTime is a struct, you cannot inherit from it, so create the following class:

    public class JsonDateTime
    {
        public JsonDateTime(DateTime dateTime)
        {
            _dateTime = dateTime;
        }
    
        private DateTime _dateTime;
    
        public DateTime Value
        {
            get { return _dateTime; }
            set { _dateTime = value; }
        }
    }
    

    Change CreateDate to this type. Next, we need a custom model binder, like so:

    public class JsonDateTimeModelBinder : IModelBinder  
    { 
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) 
        { 
            var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName).ToString(); 
            return new DateTime(Int64.Parse(
                value.Substring(6).Replace(")/",String.Empty))); // "borrowed" from skolima's answer
        }
    }
    

    Then, in Global.asax.cs, in Application_Start, register your custom ModelBinder:

    ModelBinders.Binders.Add(typeof(JsonDateTime), new JsonDateTimeModelBinder());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know if it is relevant that this is happening in an MVC
I developed an application in ASP.NET MVC. This app has an action that returns
I know that an MVC framework allows you to separate business logic, data base
I know that ASP.NET MVC will allow me to swap in various View engines
I know that ASP.NET MVC 1.0 is bin-deployable as explained in Phil Haack's article.
I know that the reason that Microsoft came out with ASP.NET MVC was to
We know that behind the scenes, the ASP.NET MVC framework will use reflection to
As discussed throughout the various MVC questions and blogposts , we know that the
I'm starting a project that will be public facing using asp.net mvc. I know
I use jquery to post to an MVC controller action that returns a table

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.