如何从Kestrel Server设置HTTP状态描述?我想回来
HTTP/1.1 400 ArgumentException
代替HTTP/1.1 400 Bad Request
,但无法在StatusDescription
中找到DefaultHttpResponse
属性,我只能使用数字代码更改StatusCode
。
以下是示例App:
https://github.com/aspnet/KestrelHttpServer/tree/dev/samples/SampleApp
答案 0 :(得分:4)
您需要访问HTTP上下文功能以覆盖原因短语,例如:
context.Response
.HttpContext
.Features
.Get<IHttpResponseFeature>()
.ReasonPhrase = "Stuff here";