using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; namespace TestWebApp.Controllers { [Route("api/[controller]")] public class ValuesController : Controller { // GET api/values [HttpGet] public IEnumerable Get() { return new string[] { "value1", "value2" }; } // GET api/values/5 [HttpGet("{id}")] public string Get(int id) { return "value"; } // PUT api/values/5 [HttpPut("{id}")] public void Put(int id, [FromBody]string value) { } // DELETE api/values/5 [HttpDelete("{id}")] public void Delete(int id) { } [HttpPost] public async Task ChectContentLength() { using (var sr = new StreamReader(Request.Body)) { var content = await sr.ReadToEndAsync(); var sb = new StringBuilder(); sb.AppendLine($"Request content length: {Request.ContentLength}"); return Content(sb.ToString()); } } } }