问题
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