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

Thanks very much for your help!

Gerry

  • You must to post comments
0
0

Following up — we tried approach #2: app.MapWhen(ctx => ctx.Request.Path.StartsWithSegments("/api"), apiApp => { apiApp.UseRouting(); apiApp.UseEndpoints(e => e.MapGet/MapPost(...)); }) registered before app.UseWisej(). Requests to /api/* still return an empty HTTP 200 and never reach our handlers (the UI at / works fine). Key detail: our app uses minimal hosting — a Shared Sub Main doing WebApplication.CreateBuilder(...), builder.Build(), then registering middleware on the app instance (UseStaticFiles, MapWhen(...), UseWisej(), UseFileServer, app.Run()) — not the classic UseStartup<Startup> template. Even a middleware registered as the very first app.Use(...) does not run for /api/*. Does Wisej require the classic UseStartup<Startup> hosting model, or is there a service registration / option for minimal hosting so UseWisej runs as an ordinary pipeline middleware and lets /api/* through to a MapWhen branch?

Thanks!

Gerry

  • Luca
    • Luca
    • Jun 25, 2026 - 6:55 pm
    Wisej doesn’t require anything, it’s just a middleware, not a service. There is no UseStartup in use. Maybe attach small plain simple test case?
  • 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 6 results
Your Answer

Please first to submit.