Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to return Problem Details responses for server errors #8537

DamianEdwards opened this Issue Mar 14, 2019 · 0 comments


None yet
3 participants
Copy link

DamianEdwards commented Mar 14, 2019

Add a set of new Problem helper methods on ControllerBase, that populates a ProblemDetails type with relevant values for simple returning of errors through the MVC response pipeline, e.g.:

private ObjectResult Problem()
    return Problem(detail: null);
private ObjectResult Problem(string detail)
    var problemDetails = new ProblemDetails
        Title = "An error occurred while processing your request.",
        Detail = detail,
        Status = 500
    problemDetails.Extensions.Add("traceId", Activity.Current?.Id ?? HttpContext.TraceIdentifier);
    return Problem(problemDetails);
private ObjectResult Problem(ProblemDetails problemDetails)
    return new ObjectResult(problemDetails) { StatusCode = problemDetails.Status };


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.