Share via

Https feedback

S Abijith 496 Reputation points
2022-05-06T06:38:07.8+00:00

Hi All,
We have a C# console application built on .Net framework 4.7. This application is acting as an HTTPS server. We are using the code attached for transferring a file from the server to a device using https protocol.

The application communicates with various devices for sending files from the server to the device.

The application works perfectly fine if the file being transferred exists. If the file does not exist, there is no feedback sent back to the device.

Unfortunately, the device does not implement timeout and as a result keeps waiting for response from the HTTPS server application.

We now want to implement a response feedback so that the device will get a response and not wait forever to receive a response from the HTTPS server application.

Can anyone please let us know the best way to get this done!!
Any help is appreciated. Thank you in advance!!

199511-putfile.txt

Developer technologies | C#
Developer technologies | 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.

0 comments No comments

Answer accepted by question author

AgaveJoe 31,361 Reputation points
2022-05-06T11:16:20.037+00:00

First, check if the file exists.

File.Exists(String) Method

Return the standard HTTP 404 (Not Found) status if the file is not found.

response.StatusCode = (int)HttpStatusCode.NotFound;

HttpListenerResponse.StatusCode Property

The client code must check the status code response. A 200 (Ok) or 404 (Not found)

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

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