Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Call `AddProblemDetailsConventions` directly on `IServiceCollection`

See original GitHub issue

To use AddProblemDetailsConventions() we must do this:

services                                // returns IServiceCollection
  .AddControllers()                     // returns IMvcBuilder        <---- here's the problem

In some environments, that IMvcBuilder isn’t available or easy to access. For example when using a modular startup, or Orchard Core. Other libraries also had this problem, it’s quite common.

All that extension method does is call IMvcBuilder.IServiceCollection. Would it be possible to add an overload (not a breaking change!) to accept that directly:

public static IServiceCollection AddProblemDetailsConventions(this IServiceCollection services)
  //identical to other overload

We could call it like so:


I would patch this myself but I never figured out the github PR thing. 😃 It would be a great improvement and add major flexibility when configuring app startup.

I hope this can be considered. Thank you!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

lonix1commented, Oct 18, 2021

Awww heck, I messed it up again 🤡 I think my PR was applied to my fork and didn’t get to this repo. Oh well I tried. It’s here BTW.

lonix1commented, Dec 6, 2021

Thanks for the new version! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling Web API Exceptions with ProblemDetails ...
In this post I describe the ProblemDetailsMiddleware by Kristian Hellang that can be used to return ProblemDetails when an exception occurs ...
Read more >
support resolving ProblemDetailsOptions from service ...
A popular way to use IOptions is to register them with the IServiceCollection and let DI take care of injecting options into middleware....
Read more >
AddProblemDetails (IServiceCollection, Action<ProblemDetailsOptions>) Adds services required for creation of ProblemDetails for failed requests.
Read more >
How to use the ProblemDetails middleware in ASP.NET Core
Configure the ProblemDetails middleware in ASP.NET Core​​ Assuming the ProblemDetails NuGet package has been installed, you should add the ...
Read more >
5 ways to set the URLs for an ASP.NET Core app - Andrew Lock
We can't directly call methods on it, but we can invoke them using reflection by building MethodInfo and calling Invoke directly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found