WebAPI with SPA (Single Page JavaScript) Specifically ExtJS and Sencha Touch

I’ve really gotten to like using Microsoft’s ASP.NET WebAPI with JavaScript.  No longer do I have to worry about the JSON conversion and error status.  With a very simple pattern of what to return, it just works. In this post, I’m just going to show the code for the controller itself.  Not any kind of camelcase filters, error handling, security, or anything else.  Just the simple controller.  All those other things can be handled without touching the code I’m showing here. Basically, all we have to do is create an HttpResponseMessage and return that.  The code I have below is actually production in Silicon Valley Code Camp and just returns a list of all the session levels.  It’s pretty self explanatory. … Continue Reading

Collection Form Post Parameters in WebAPI Controller

There are lots of ways using ASP.NET MVC4 to collection passed in form parameters (POST) to the WebAPI Controller.  I’m not wanting to create a Model, I’m not wanting to get involved with dynamic variables, I just want the values that are posted in.  Say for example, my post looks like the following: To capture both sessionId and trackId, I can have a WebAPI controller in Visual Studio that looks just like this: namespace WebAPI.Api{ public class SessionRpcController : ApiController { [HttpPost] [ActionName("UpdateSessionTrack")] [Authorize(Roles = "admin")] public HttpResponseMessage PostUpdateSessionTrack( FormDataCollection formDataCollection) … Continue Reading

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

ImageResizer, Amazon’s CloudFront and ASP.NET’s MVC4 Razor Helper Methods

  Well, the title is certainly a mouthful and hopefully a honey trap for SEO.  The thing is, I’m really going to talk about all those things.  I just went through a short exercise that I thought would be useful to share. Background For Silicon Valley Code Camp, I use the toolkit ImageResizer written by  Nathanael Jones.  For those of you that deal with any quantity of images on their web sites, I strongly recommend taking a look at this.  Before I used this toolkit I written my own image handlers that did some similar things but not nearly as well or with so many features.  One of the issues we have on code camp is that we try and show lots of pictures all the time.  Sponsors and speakers are … Continue Reading

Follow

Get every new post delivered to your Inbox

Join other followers: