Created
May 6, 2017 19:43
-
-
Save aramkoukia/5c1e555d2fd52f342b4cd32b58232b6c to your computer and use it in GitHub Desktop.
.net core controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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