You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[HttpGet("status/{statusCode}")]
public IActionResult Status([FromRoute] int statusCode)
{
return StatusCode(statusCode);
}
Content-Type: "application/problem+json"
β This code fails to call the middleware.
[HttpGet("conflict")]
public IActionResult ConflictCheck()
{
var error = new ProblemDetails
{
Type = "https://httpstatuses.com/409",
Title = "Agent was already modified.",
Status = StatusCodes.Status409Conflict,
Instance = "/test/conflict",
Detail = "agent was already modified after you retrieved the latest data. So you would then override the most recent copy. As such, you will need to refresh the page (to get the latest data) then modify that, if required."
};
return StatusCode(409, error);
}
Content-Type: "application/json"
The reason (which is why this is similar to #2) is because, for the 2nd (not working) example ... when it calls if (Options.IsProblem(context)) (ref: your source code) that returns false. The reason why it returns false is this:
My guess is that, in the first (working) example, there is no model .. so there is nothing to write ... so no content-type was set. Where-as in the second example there is a model provided, so it must write the content-type out before the ProblemDetails middeware is invoked?
I'm not sure what the best solution here, is?
The text was updated successfully, but these errors were encountered:
This is really a duplicate of #5. The best solution is to follow the workaround there, or wait for ASP.NET Core 2.2, which implicitly adds the correct content type for ProblemDetails types π
Hi π
NOTE: this issue is very similar to #2 .
When trying to return a
StatusCode
result, the middleware isn't invoked iff I provide a model (in this case, aProblemDetails
instance).β Works.. (this code taken from your samples-code)..
"application/problem+json"
β This code fails to call the middleware.
"application/json"
The reason (which is why this is similar to #2) is because, for the 2nd (not working) example ... when it calls
if (Options.IsProblem(context))
(ref: your source code) that returnsfalse
. The reason why it returns false is this:My guess is that, in the first (working) example, there is no model .. so there is nothing to write ... so no content-type was set. Where-as in the second example there is a model provided, so it must write the content-type out before the
ProblemDetails
middeware is invoked?I'm not sure what the best solution here, is?
The text was updated successfully, but these errors were encountered: