0

tcp – Getting 403 without a request being sent

#tcp #request

I’m trying to figure out why I get a 403 HTTP response when trying to access a certain url using HttpClient in C#.

I know it may seem like this question would be a good fit for stackoverflow, but the actual puzzle is with networking, bear with me.

Initially I believed it to be because CloudFare was blocking any no-javascript request.

I get a 200 no problem for the same url using Postman.

I copied the headers from the Postman request and added them to my application it failed again.

So I decided to just capture both packets using Wireshark and see where the differences lie.

I captured the Postman packets without any issue but, for some reason, my C# code doesn’t seem to actually send any request, at all.

This is my code, for anyone curious:

    var client = new HttpClient();
    var response = client.GetStringAsync(url).GetAwaiter().GetResult();

Before I start the execution, I open Sysinternals’ TCPView and filter by the executable name, then I start the code.

(TCPView is a tool which shows all processes on the system that are using a network port for communication with information about the protocol and etc.)

Nothing shows up in TCPView.

If I change url to be something like https://www.google.com then an entry shows up in TCPView and if I filter by the source port shown there I can see the packets in Wireshark. But the same does NOT happen with the original url.

Does anyone have any idea why I can’t see any semblance of a request leaving my system?