Call `AddProblemDetailsConventions` directly on `IServiceCollection`
See original GitHub issueTo use AddProblemDetailsConventions()
we must do this:
services // returns IServiceCollection
.AddControllers() // returns IMvcBuilder <---- here's the problem
.AddProblemDetailsConventions();
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:
services.AddProblemDetailsConventions();
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:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top 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 >ProblemDetailsServiceCollection...
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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Thanks for the new version! 😄