Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1045

Set charset different from UTF-8 in JSON Response

$
0
0

I have this get request in my controller in ASP.NET Core project

[HttpGet][Route("api/controller/getlastresult/{id}")]public IActionResult GetLatestResultForController(string id){    Response.ContentType = "application/json";    var list = _dbAccessLayer.GetAllVoteResults();    var appropriateResults = list.Where(item => item.DeviceId.Equals(id) && item.Status == "Finished")        .OrderBy(item => item.TimeStarted);    if (appropriateResults.Any())        return Ok(Json(appropriateResults.Last().Result));    return BadRequest();}

It works fine, but in the headers there is Content-Type: application/json; charset=utf-8 as you can see here:

enter image description here

I need just regular application/json, without charset utf-8, so I guess it will be ASCII charset. Reason being that I use this request with microcontroller which does not like utf-8 encoding.

How do I set charset in the response of my Get request?


Viewing all articles
Browse latest Browse all 1045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>