Skip to content

Don't set StatusCode in WriteAsJsonAsync #23516

@ansarizafar

Description

@ansarizafar

Route to code is a great new addition to Asp.net core. New Apis like WriteAsJsonAsync() and ReadFromJsonAsync() are great for creating lightweight endpoints without using API controllers.

Like API controllers we should also have Ok() and BadRequest() methods available on HttpContext.Response object for sending proper response.

I would also like to suggest that WriteAsJsonAsync() should allow setting HttpStatus code. Currently StatusCode is set to 200 by this method.

Metadata

Metadata

Assignees

Labels

area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions