Using Renegotiation in C#

S Abijith 386 Reputation points
2024-09-14T20:10:04.57+00:00

Hi All,

We have a WPF application built on .Net Framework 4.8. This application acts an HTTPs client. We are currently using the code provided in the attached file for HTTPs communication. This code is used to run a sequence of commands one after another.

We are able to see in Wireshark traces that the connection is currently using 'Session Resumption' each time a new command is executed, but we want to renegotiate the connection rather than session resumption.

Can anyone let us know as to how this can be done?

Any help is appreciated!

Thank you in advance!

Code used: HttpsConnection.txt

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,762 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,858 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Hongrui Yu-MSFT 1,605 Reputation points Microsoft Vendor
    2024-09-16T06:26:53.7233333+00:00

    Hi,@S Abijith. Welcome to Microsoft Q&A. 

    If you want to reconnect every time you send a request, you could try the following method.

    Method 1: Set request.KeepAlive = false;

    Related Documents: HttpWebRequest.KeepAlive Property (System.Net) | Microsoft Learn

     

    Method 2:Set request.ServicePoint.ConnectionLeaseTimeout = 0;

    Related Documents: ServicePoint.ConnectionLeaseTimeout Property (System.Net) | Microsoft Learn


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.