.HttpContext.Features.Get< IHttpResponseFeature>()。ReasonPhrase在.net core 2.1中不起作用? [英] .HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase is not working in .net core 2.1?

查看:517
本文介绍了.HttpContext.Features.Get< IHttpResponseFeature>()。ReasonPhrase在.net core 2.1中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用以下代码在HTTP请求中将自定义消息从服务器端发送到客户端。它在 .NET Core 2.0

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

而在 .NET Core 2.1 ,它不起作用。它不会引发任何脚本错误,但是我们无法获得客户端成功的消息。

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.

如何解决此问题?

推荐答案

我希望它回答了您的问题:

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.

2.0项目模板默认未启用HTTPS,即
2.1模板可以。使用HTTP时,浏览器使用HTTP / 1.1,ReasonPhrase可以正常工作。使用HTTPS时,浏览器使用
HTTP / 2,并且ReasonPhrase不再起作用。

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.

克里斯·罗斯(Chris Ross)的完整答案此处

Full answer by Chris Ross here.

这篇关于.HttpContext.Features.Get&lt; IHttpResponseFeature&gt;()。ReasonPhrase在.net core 2.1中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆