I have an ASP.NET Core with the following controller that accepts a POST request:
[Route("api/v1/tenants/tests")]
public class TestsController : Controller
{
[HttpPost]
public IActionResult Post(string tenantId)
{
return Ok();
}
}
I have developed a 'null' middleware to test things out. It is defined in the Configure
method of the Startup.cs
file:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
app.Use(async (context, next) =>
{
// Forward to the next one.
await next.Invoke();
});
}
Question
When I call the controller via Postman, the initial call to the POST
method goes successfully through the middleware and then to the Controller. However, the following calls directly go to the Controller, skipping the middleware entirely. Why is that?