Monday, April 25, 2016

WebAPI plain text response

I got a problem where the solution was to create a globe JavaScript object and I need to render the data on the server.

I would like to use the JavaScript object like:

<span id="text"></span>
var d = document.getElementById("text");
d.innerText = resources.hello;

I started by creating a WebAPI controller and return a string through the Ok method. And end up with this:


This is not JavaScript and there for I can’t use it.

I found an article by Mike Wasson ( Where he creates a new IHttpActionResult.

With this new class. I can control the output. So it will be like this:


No comments:

Post a Comment