Closed mudebug77 closed 7 months ago
Hello @mudebug77, thanks for using EmbedIO!
The behavior you point out is not a bug: in fact, it is exactly how EmbedIO is supposed to work. All data returned from the methods of a Web API controller will be serialized the same way: by default, JSON serialization is used.
There are two ways to customize serialization for Web APIs:
void
and completely handle the response inside it, as explained in the responses to #467.I hope this helps. I also took the liberty of editing the title of this issue, hopefully making it more probable to be found in future searches by someone having a similar problem.
Describe the bug The TestString endpoint returns a string with double quotes ("Test") instead of the expected content (Test).
To Reproduce
Access the 'TestString' endpoint. See the returned content with double quotes. Expected behavior The 'TestString' endpoint should return the content "Test" without any additional double quotes.
Additional context The issue may be related to the default serialization behavior of EmbedIO, which may treat the returned string as JSON. To resolve this, set the Content-Type header to "text/plain" to indicate that the content is plain text.
csharp Copy code [Route(HttpVerbs.Any, "/TestString")] public async Task TestString()
{
// Set Content-Type to text/plain
HttpContext.Response.ContentType = "text/plain";
} This should ensure that the content is treated as plain text and does not include additional double quotes.