WebLog Posts in Category Web Api


Accepting Raw Request Body Content with ASP.NET Web API
December 13, 2013 @ 3:35am

One ASP.NET Web API related question that frequently comes up frequently is how to capture the raw request content to a simple parameter on a controller method. Turns out that's not as easy as it should be. In this post I discuss how to natively capture the raw request content and then create a [NakedBody] attribute that makes it easy capture the raw content in a string or byte[] parameter.

9 comments
A WebAPI Basic Authentication MessageHandler
April 30, 2013 @ 3:29am

In my last post I showed how to create a basic authentication filter for custom authentication within your applications. This time I repeat the excercise with a MessageHandler to demonstrate the differences between the two approaches.

10 comments
A WebAPI Basic Authentication Authorization Filter
April 18, 2013 @ 11:35am

Recently I needed to implement user based security in a Web API application that's easily accessible from a variety of clients. The customer asked specifically for Basic Auth support and so needed to implement custom Basic Auth support. In this post I describe a simple AuthorizationFilter based implementation of Basic Authentication for Web API.

23 comments
WebAPI: Getting Headers, QueryString and Cookie Values
April 15, 2013 @ 3:48am

Finally got tired to trying to remember how to get at the Headers, Cookies and QueryString 'collections' in Web API, since there's zero consistency and messy nested collections to deal with. Here's are a set of extension methods that make it easier.

7 comments
Passing multiple simple POST Values to ASP.NET Web API
September 11, 2012 @ 4:27am

One feature conspicuously missing from ASP.NET Web API is the inability to map multiple urlencoded POST values to Web API method parameters. In this post I show a custom HttpParameterBinding that provides this highly useful functionality for your Web APIs.

13 comments
ASP.NET Frameworks and Raw Throughput Performance
September 04, 2012 @ 6:13pm

I got curious the other day: How do the various ASP.NET framework compare in raw throughput performance? With so many development choices on the ASP.NET stack available today it's interesting to take an informal look at how raw throughput performance compares.

23 comments
Using JSON.NET for dynamic JSON parsing
August 30, 2012 @ 5:04am

Parsing JSON dynamically rather than statically serializing into objects is becoming much more common with today's applications consuming many services of varying complexity. Sometimes you don't need to map an entire API, but only need to parse a few items out of a larger JSON response. Using JSON.NET and JObject,JArray,JValue makes it very easy to dynamically parse and read JSON data at runtime and manipulate it in a variety of different ways. Here's how.

21 comments
An Introduction to ASP.NET Web API
August 21, 2012 @ 2:41am

This article is a hands on tour of ASP.NET Web Api. It covers a fair variety of functionality and goes beyond the most basic introductions by digging into some of the mundane details you're likely to run when first starting out with Web API.

12 comments
Mapping UrlEncoded POST Values in ASP.NET Web API
August 16, 2012 @ 12:42pm

Surprsingly Web API does not support POST value mapping to multiple simple parameters on a Web API endpoint. While you can map POST values with model binding or the FormDataCollection native parameter mapping in Web API is a missing feature. Here's what you can and can't do with POST values in Web API.

10 comments
Where does ASP.NET Web API Fit?
August 07, 2012 @ 4:34pm

With the pending release of ASP.NET Web API we're finally getting a good HTTP Service solution 'in the box ' in ASP.NET. Web API provides many needed and cool features, but it's not always clear whether you should use Web API or some other technology like MVC to handle HTTP service requests. In this post I discuss what Web API is and a few options of where it fits and potentially doesn't fit.

22 comments
Passing multiple POST parameters to Web API Controller Methods
May 08, 2012 @ 10:29pm

Web API allows for RPC style method access, but there are differences from older Microsoft AJAX APIs when it comes to passing multiple parameters. Here's how Web API handles parameters and how you can optionally manage multiple parameters to API Controller methods.

30 comments
Creating a JSONP Formatter for ASP.NET Web API
April 02, 2012 @ 5:03pm

Web API doesn't include native JSONP support, but it's pretty easy to create a custom formatter that handles this task. Here's how to create a JsonpFormatter and hook it up as well as a short review of how JSONP works.

32 comments
ASP.NET Web API and Simple Value Parameters from POSTed data
March 21, 2012 @ 5:05pm

There are a few odd behaviors with Web API and its handling of simple parameters to Controller methods. While complex values serialize just fine, simple values like strings and dates and form variables require special attention.

11 comments
Dynamic JSON Parsing in .NET with JsonValue
March 19, 2012 @ 3:09am

The JsonValue/JsonObject/JsonArray classes in the System.Json are new for the full .NET framework and recently introduced with the various betas of ASP.NET (and previously WCF) Web API. JsonValue fills the need for dynamically parsing and serializing of JSON at runtime.

12 comments
Using an alternate JSON Serializer in ASP.NET Web API
March 09, 2012 @ 3:30am

The default serializer in ASP.NET Web API (at least in Beta) is the DataContractJsonSerializer with all of its warts and inability to not serializer non-typed objects. In this post I'll talk about the issues and how to plug-in alternate JSON parsers to handle more complete JSON serialization in Web API.

23 comments
Removing the XML Formatter from ASP.NET Web API Applications
March 09, 2012 @ 1:51am

When viewing ASP.NET Web API output in browsers the content is usually displayed as XML which is not my preferred choice. Even though JSON is Web APIs default format XML continues to be displayed. Here's some discussion on why this happens and how you can work around it.

11 comments


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2014