Skip to content

[Enhancement] What is the suggestion for TypedResults using e.g. Problem WITH a Redirect? #36476

@DevTKSS

Description

@DevTKSS

Description

I am looking into the Social Auth sample here:

https://github.com/dotnet/aspnetcore/blob/4b30be10dea772f6c398b68be1506db6b6acf7f2/src/Security/Authentication/samples/SocialSample/Startup.cs#L385-L390

and would like to Upgrade this to TypedResults to ensure type security 🚀
but now I am a bit stuck with how I can combine a TypedResult.Problem which I would assume to be the closest to the "regular" NotSupportedException we would use on non web targets and the go-to for web is to not throw exceptions then use the return value instead.
The original return has been nothing, but it was also using .Run( which I don't see combine-able with IRouteGroupBuilder .

What I came up with so far:

 return TypedResults.Problem(title: $"Provider not supported", detail: "<html><body>No refresh_token is available.<br><a href=\"/\">Home</a></body></html>", statusCode:StatusCodes.Status501NotImplemented);

As there is no extension for Problem like .Problem(...).RedirectToRoute("/") and RedirectToRoute has no message to add, I would assume that the extensions overload of it could eventually be used for this ?
But I was unable to find a sample in the current documentation, how I could/should use this 🤔

Could someone recommend something for this to me please and add some note to the docs for others too?

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/error-handling-api?view=aspnetcore-10.0&tabs=minimal-apis

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/error-handling-api.md

Document ID

5ad65468-c51c-9899-c435-6e99d734d0b8

Platform Id

bc49b255-ac35-3229-e350-58e76d52238c

Article author

@brunolins16

Metadata

  • ID: 5ad65468-c51c-9899-c435-6e99d734d0b8
  • PlatformId: bc49b255-ac35-3229-e350-58e76d52238c
  • Service: aspnet-core
  • Sub-service: fundamentals

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions