Wrestling All Day With WebAPI, NewtonSoft and JSON Date Formats

  Half to document what I now believe and half to share my findings, I’m going to do a short post that shows the implications of changing the DateTimeKind parameter of a DateTime field in a WebAPI controller.  That is, a WebAPI controller can return it’s results as JSON and the data that is DateTime gets converted based on some rules that for me were not clear. First, let me state my conclusion (for those with short attention spans), then I’ll show the data and include the visual studio 2012 project I used to make this. DateTimeKind.Local 013-10-05T13:00:00-07:00 (Has Timezone) DateTimeKind.Utc 2013-10-05T13:00:00Z (Has Z) DateTimeKind.Unspecifed … Continue Reading

Microsoft’s ASP.NET MVC Lite, Building a TextReformatter With JsonResult

  Introduction   People often ask me if I use MVC or WebForms for my Microsoft ASP.NET projects.  I always tell them MVC, but I don’t use it in the classic way that most others do.  That is to say, I emit no html from my views, and for that matter really don’t even use views (with the exception of one view which is essentially my entire app.   People often refer to this as a SPA or Single-Page-Application. What this basically means is that my entire view is built with JavaScript (in my case Sencha’s ExtJS) and the only interaction with the server is to simply bring down Json results. In this post, I’m going to build a simple app following this principle. It’s purpose will be to take a big pile of text, chop … Continue Reading

MVC3 Unable To Return Large JSON Even with Web Config Patch, Using LargeJsonResult Instead

I’m trying to download a base64 encoded image that is about 4 Megabytes embedded inside a JSON object.  When I first tried this from my MVC3 Web application, I got the error: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. … Continue Reading

Returning JsonResult From ASP.NET MVC 2.0 Controller and Unit Testing

* I’m adding this comment after the post has been written to let anyone coming here know of another great post that goes further to explain no only what I’ve done here, but also two other ways including Mock and using Json Serialization.  The Post is written by Ashic Mahtab, aka “HeartattacK” on the forums.  His well written and informative article is here:  ASP.NET MVC – Unit Testing JsonResult Returning Anonymous Types. This post will show how to return a simple Json result from an ASP.NET MVC 2.0 web project.  It will show how to test that result inside a unit test and essentially pick apart the Json, just like a JavaScript (or other client) would do.  It seems like it should be very simple (and indeed, once … Continue Reading


Get every new post delivered to your Inbox

Join other followers: