Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The return array is empty. #596

Closed
simphonydeveloper opened this issue May 20, 2024 · 1 comment
Closed

The return array is empty. #596

simphonydeveloper opened this issue May 20, 2024 · 1 comment

Comments

@simphonydeveloper
Copy link

Describe the bug

this is my configuration.

        var server = new WebServer(o => o
                .WithUrlPrefix(url)
                .WithMode(HttpListenerMode.EmbedIO))
            // First, we will configure our web server by adding Modules.
            .WithLocalSessionManager()
            .WithWebApi("/api", m => m
            .WithController<BasicController>())
            //.WithModule(new WebSocketChatModule("/chat"))
            //.WithModule(new WebSocketTerminalModule("/terminal"))
            //.WithStaticFolder("/", HtmlRootPath, true, m => m
            //.WithContentCaching(UseFileCache)) // Add static files after other modules to avoid conflicts
            .WithModule(new ActionModule("/", HttpVerbs.Any, ctx => ctx.SendDataAsync(new { Message = "Error" })));

        //server.Options

        // Listen for state changes.
        server.StateChanged += (s, e) => {
            Console.WriteLine($"WebServer New State - " + e.NewState);
            $"WebServer New State - {e.NewState}".Info();
        };

Embedio

  • Version 3.5.2

Screenshots
image

Desktop (please complete the following information):

  • OS: WIN10
  • Version app .net farmworker version 4.6.1
  • API TEST Tool:POSTMAN
@simphonydeveloper
Copy link
Author

I have found a solution
#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" })));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant