如何设置 Kestrel 服务器的 HTTP 状态描述?我想回来
HTTP/1.1 400 ArgumentException
而不是 HTTP/1.1 400 Bad Request
,但在 DefaultHttpResponse
中找不到 StatusDescription
属性,我只能用数字代码更改 StatusCode
。
这是示例应用程序:
https://github.com/aspnet/KestrelHttpServer/tree/dev/samples/SampleApp
最佳答案
您需要访问 HTTP 上下文功能来覆盖原因短语,例如:
context.Response
.HttpContext
.Features
.Get<IHttpResponseFeature>()
.ReasonPhrase = "Stuff here";
关于c# - 如何从 Kestrel 服务器设置 StatusDescription?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40040794/