below is the code:
public class Startup
{
// ...
public void Configure(IApplicationBuilder app)
{
app.UseRouting();
app.Use(async (context, next) =>
{
await context.Response.WriteAsync("write sth first\n");
await next();
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
I got only "write sth first" response, the content generated by controller's action method is not appended to the response. However, I put a debugger on the action method of the controller, the debugger was hitting, which means the MVC pipeline was still running(which is not really short circuit) then why the response from action method is not in the response?
What's confusing me more is, if I change the code to:
public class Startup
{
// ...
public void Configure(IApplicationBuilder app)
{
app.UseRouting();
app.Use(async (context, next) =>
{
await context.Response.WriteAsync("write sth first\n");
await next();
});
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context => {
await context.Response.WriteAsync("Hello World!");
});
});
}
}
then I got a response that is "write sth first\n "Hello World!", so why this time the response from the endpoint is appended to the Response?
Is anywhere in endpoints.MapControllers() that check the HttpContext.Response like if there is content then abort the remaining process? where is the source code for this part?
