Collection Form Post Parameters in WebAPI Controller

image.png

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

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

image.png

  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

Meetup At Sencha Headquarters Tomorrow (Tuesday 8/23) in Redwood City Talking MVC in JavaScript!

image.png

Tomorrow night (Tuesday, August 23rd), we are having another meetup to talk about using MVC inside of Sencha’s JavaScript products.  I (Peter Kellner) will be talking for the first 20 minutes about how we are integrating the MVC pattern in our Silicon Valley Code Camp web site, then Ed Spencer from Sencha will follow on talking a lot more about MVC and best practices as well as Q&A Hope you can make it.  Details are here: http://www.meetup.com/The-San-Francisco-ExtJS-Meetup-Group/events/28760211/   … Continue Reading

DevConnections Presentation Orlando, How To Make Your Browser fly

(About 100 People) The Presentation was broken down into three parts.  Part 1 Created a windows razor project that cached in image on a web site using best practices for threading and locking.  The code and project to do this are below: var downloadByteArray = HttpContext.Current.Cache[cacheName] as byte[]; if (downloadByteArray == null) { // make sure multiple requestors are not filling up the cache lock (LockVal) { downloadByteArray = HttpContext.Current.Cache[cacheName] as byte[]; if (downloadByteArray == null) { Thread.Sleep(sleep * 1000); string imageLocation = HttpContext.Current.Server.MapPath("~") + imageUrl; downloadByteArray = … Continue Reading

Follow

Get every new post delivered to your Inbox

Join other followers: