Skip to content

How to "convert" a request into a 404? #593

Answered by Tratcher
PieterBoeren asked this question in Q&A
Discussion options

You must be logged in to vote

How about using a standard route instead of a proxy route?

endpoints.Map("/api/{*anything}", context => { context.Response.StatusCode = StatusCodes.Status404NotFound; return Task.CompletedTask; });

By the way, middleware should only call Abort if they don't want the response to be sent. If they do want it to be sent then they should return early / not call next.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PieterBoeren
Comment options

Answer selected by PieterBoeren
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants