DateTime from Javascript post to Controller in ASP.NET results in null (01/01/0001)
Posted
by Geoffrey
on Stack Overflow
See other posts from Stack Overflow
or by Geoffrey
Published on 2010-06-10T20:25:08Z
Indexed on
2010/06/10
20:42 UTC
Read the original article
Hit count: 364
This is driving me crazy, similar to this. If I use a standard form and no javascript the controller correctly binds the datetime. However when I'm posting from a form it always binds as null:
"MyObject.Name": "Test name",
"MyObject.Date": "5/1/2001"
I've tried a couple of variations, 5-1-2001, etc. but cannot seem to get it to take. I can confirm that it is being passed to the server as it shows up in the Request.Form string. My culture is Gregorian and I've set:
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
In Application_BeginRequest(). What gives?
© Stack Overflow or respective owner