Skip to content

Instantly share code, notes, and snippets.

@aramkoukia
Created May 6, 2017 19:43
Show Gist options
  • Select an option

  • Save aramkoukia/5c1e555d2fd52f342b4cd32b58232b6c to your computer and use it in GitHub Desktop.

Select an option

Save aramkoukia/5c1e555d2fd52f342b4cd32b58232b6c to your computer and use it in GitHub Desktop.
.net core controller
[Route("api/[controller]/[action]")]
public class ValuesApiController : ApiController
{
[HttpGet]
[ActionName("GetArray")]
public IEnumerable GetArray()
{
return new string[] { "value2", "value3" };
}
[HttpGet]
[ActionName("GetSomeJson")]
public HttpResponseMessage GetSomeJson()
{
//example returns a HttpResponseMessage
var resp = new HttpResponseMessage()
{
Content = new StringContent("[{\"Name\":\"ABC\"},[{\"Id\":\"1\"}]]")
};
resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
return resp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment