问题
We are using the code below to send the custom message from server side to client side in HTTP request. It is working properly in .NET Core 2.0
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase
While using the same code in .NET Core 2.1
it does not work. It doesn't throw any script errors but we couldn't get message in client side success.
How to resolve this problem?
回答1:
I hope it answers your question:
This is not caused by any code changes in the framework, it's caused by a project configuration change.
The 2.0 project templates did not have HTTPS enabled by default, the 2.1 templates do. When using HTTP the browser uses HTTP/1.1 and ReasonPhrase works as expected. When using HTTPS the browser uses HTTP/2 and ReasonPhrase no longer works.
Full answer by Chris Ross here.
来源:https://stackoverflow.com/questions/54285164/httpcontext-features-getihttpresponsefeature-reasonphrase-is-not-working-in