How to enable Connection:Keep-Alive for aps.net core 2.1

人走茶凉 提交于 2021-01-29 07:14:34

问题


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.


回答1:


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:



来源:https://stackoverflow.com/questions/57873617/how-to-enable-connectionkeep-alive-for-aps-net-core-2-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!