Browsed by
Tag: web api

Returning binary file from controller in ASP.NET Web API

Returning binary file from controller in ASP.NET Web API

Source Try using a simple HttpResponseMessage with its Content property set to a StreamContent:

A few things to note about the stream used: You must not call stream.Dispose(), since Web API still needs to be able to access it when it processes the controller method’s result to send data back to the client. Therefore, do not use a using (var stream = …) block. Web API will dispose the stream for you. Make sure that the stream has its current position set to 0 (i.e. the beginning of the stream’s data)….

Read More Read More

WEB API 2 EXPLORING PARAMETER BINDING

WEB API 2 EXPLORING PARAMETER BINDING

Source This article demonstrates how to call or map Web API methods with different types of parameters using XML, Json and Urlencoded formats. It shows how simple parameters, objects parameters and array parameters can be sent either in the body of the Http request or in the Url itself. This all works per default in Web API and if that’s not enough, you can customize it yourself. code: https://github.com/damienbod/WebApiParameters Simple Parameters Example 1: Sending a simple parameter in the Url 1 2…

Read More Read More

Send string array to web api

Send string array to web api

You can send it in the body or the URL URL:

or in the body:

Here’s example of parameters bindings: http://damienbod.wordpress.com/2014/08/22/web-api-2-exploring-parameter-binding/