6

Thanks to the extensive ASP.NET Core documentation, we know what is happening at high-level but I also want to dive deep to understand what is exactly happening while built-in middlewares are executing in a debugging session.

I can, of course, enable source linking and source stepping to further continue stepping over the framework code but only if starting from a breakpoint available on my side.

Hence, I was wondering if there is a straightforward way to fully step over all the framework code about the executed middleware components. For example; debugging UseRouting() step by step from the beginning or UseAuthentication() and etc.

Thanks in advance!

1

1 Answer 1

0

You can add an app.Use() immediately after calling app = builder.Build();

var app = builder.Build();

app.Use((context, next) =>
{
    return next();
});

app.UseAuthentication(); // You might need to explicitly add some middleware after your use statement to avoid it being auto-magically added before you can start debugging.

And add a debug point on return line.

Sometimes this doens't get you right at the start of the pipeline, there are some internal stages that can be added before your first entry runs. Some of these can be moved by setting them explicitly in your pipeline. e.g. to step through the authentication middleware you need to explicitly add app.UseAuthentication() after your app.Use(...) statement otherwise it will be auto-magically added into the pipeline before you can get to it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.