本文介绍了如何为aps.net Core 2.1启用Connection:Keep-Alive的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net core 2.1网站在Windows服务器上运行,作为一种天蓝色的Web应用程序.我被要求启用保持活动",以便当客户端要求"Connection:Keep-Alive"时,连接不会关闭.我找不到有关如何执行此操作的任何文档(即使有可能也是如此).

获得持久连接(如果这是正确的术语)的原因是为了减少SSL协商的开销.

我确实找到了这个问题:

因此,您可以在项目中手动添加一个web.config文件:

然后选择Web配置文件

然后,您可以添加配置:

 <?xml version ="1.0" encoding ="utf-8"?><配置>< system.webServer>< httpProtocol allowKeepAlive ="true"/></system.webServer></configuration> 

最后,部署您的项目,配置将在kudu中更新:

I have an asp.net core 2.1 website running on a windows server as an azure web app. I was asked to enable "keep-alive" so that when a client asks for "Connection:Keep-Alive" the connection is NOT closed. I cant find any documentation on how to do this (nor if this is even possible).

The reason for getting a persistent connection (if this is the correct term) is to reduce the overhead from the SSL negotiation.

I did find this: Azure Website Connection Keep-Alive stack-overflow question. The provided answer doesn't help. There is no web.config file in asp.net core web apps. i didn't find anything else regarding Keep-Alive in asp.net core.

解决方案

Actually, there will still be a web.config file for IIS in web app. After you publish your .NET Core web app, you can use Azure Kudu tools from portal to checks files, and you will find the web.config generated by system.

So, you can manually add a web.config file in your project:

And then choose web configuration file

Then, you can add your configurations:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <httpProtocol allowKeepAlive="true" />
  </system.webServer>
</configuration>

Finally, deploy your project, and configurations will be updated in kudu:

这篇关于如何为aps.net Core 2.1启用Connection:Keep-Alive的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 12:53