Json string gets escaped in web-api
asp.net-mvc-5, asp.net-web-api, c#, json.net
Solution
You can return a `HttpResponseMessage` from the ApiController which allows you to basically return a string value.
e.g.
public HttpResponseMessage Get()
{
return new HttpResponseMessage() {
Content = new StringContent("Hello World", System.Text.Encoding.UTF8, "application/json")
};
}
What you would want to do is just pass the json string as the StringContent.
Problem
we have JSON configuration data stored in a database. i need to fetch this JSON data and return it, as it is, to the browser via asp.net web-api: ``` public class ConfigurationController : ApiController { public string Get(string configId) { // Get json from database // when i return the fetched json it get's escaped } } ``` The value that i return gets escaped. how do i simply return the string as it is? I really don't want to populate an object that gets serialized to JSON.