Custom REST endpoints

0
0

Hi!

We have a Wisej.NET 4 app (.NET 8, in-process on IIS/Azure App Service). We need custom REST endpoints under /api alongside the Wisej UI. We use minimal hosting (WebApplication.CreateBuilder in a Startup.Main, not UseStartup<Startup>). We register endpoints with app.MapGet/MapPost, and also tried the template order app.UseWisej(); app.UseRouting(); app.UseEndpoints(...). In every case our custom routes (e.g. GET /data, /api/health) return an empty HTTP 200 — Wisej handles them and never passes them to our endpoints, while the UI at / works fine. What is the exact required setup (services registration, hosting model, middleware order) so custom /api endpoints reach ASP.NET Core instead of being swallowed by Wisej? Is classic UseStartup<Startup> hosting required, and is there a Wisej service registration we’re missing?

 

Thanks!

Gerry

 

  • You must to post comments
0
0

I just tried using 3 standard approaches (using chatgpt):

var app = builder.Build();
app.UseRouting();
app.MapGet("/api/test", async context =>


var app = builder.Build();
// API endpoint FIRST, before Wisej.
app.MapWhen(
   context => context.Request.Path.Equals("/api/test", StringComparison.OrdinalIgnoreCase),
var app = builder.Build(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGet("/api/test", async context =>

They all work.

 

  • You must to post comments
0
0

It is not possible for any middleware to change the order in which the server invokes it. They are a chain.

  • You must to post comments
0
0

Thanks. We placed our endpoints (UseRouting + UseEndpoints with MapGet/MapPost) before app.UseWisej(), but requests to our routes (e.g. GET /data, /api/health) still return an empty 200 and never reach the endpoints — the UI at / works. Note we do not use the classic UseStartup<Startup> template; we use minimal hosting: a Shared Sub Main that calls WebApplication.CreateBuilder(...), builder.Build(), then registers middleware on the app (app.UseStaticFiles, app.UseRouting, app.UseEndpoints(...), app.UseWisej(), app.Run()). Our diagnostics show Wisej intercepts these routes even ahead of a middleware registered as the very first app.Use(). Does Wisej require classic UseStartup<Startup> hosting, or is there a service registration (normally in the template’s ConfigureServices) we’re missing so UseWisej runs as a normal pipeline middleware in registration order?

Gerry

  • You must to post comments
0
0

Middlewares (UseAbc() are middlewares) are processed in the order they are registered. Place your endpoints processing before wisej.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.