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

查看:22
本文介绍了.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<IHttpResponseFeature>().ReasonPhrase 在 .net core 2.1 中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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