Closed simphonydeveloper closed 3 months ago
I have found a solution https://github.com/unosquare/embedio/issues/467
public static async Task SerializationCallback(IHttpContext context, object data)
{
Validate.NotNull(nameof(context), context).Response.ContentType = MimeType.Json;
using ( var text = context.OpenResponseText(new UTF8Encoding(false)))
{
await text.WriteAsync(JsonConvert.SerializeObject(data, new Newtonsoft.Json.JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Serialize
})).ConfigureAwait(false);
}
}
var server = new WebServer(o => o
.WithUrlPrefix(url)
.WithMode(HttpListenerMode.EmbedIO))
// First, we will configure our web server by adding Modules.
.WithLocalSessionManager()
.WithWebApi("/api", SerializationCallback, m => m.WithController(() => new BasicController()))
.WithModule(new ActionModule("/", HttpVerbs.Any, ctx => ctx.SendDataAsync(new { Message = "Error" })));
Describe the bug
this is my configuration.
Embedio
Screenshots![image](https://github.com/unosquare/embedio/assets/118798499/7103e01d-b734-41bb-abe8-fce030367970)
Desktop (please complete the following information):