.NET Core Console App - HttpWebRequest


#1

I hope this is the correct forum. I know .NET Core is a relatively new technology, I am not finding any solution to my issue. I am guessing because there is just not enough information available.

So I have a console app I wrote in .NET 5 years ago, it is still running beautifully. In the 5 years it has never failed me, it runs multiple times a day. Because of lack of cooperation on gathering data from another division at my job, mainly from work politics, I had to gather the data for my office by doing HTTP post and logging into the other units website and then navigating through and pushing more post request, to gather bracket delimited data through an account.

I had left that office 5 years ago, but a few months ago I moved back. The application needs to be rewritten because at this point it is insecure and will not pass security testing. I would love to rewrite everything, including the front end. in .NET core and ASP Net Core. I started rewriting it and surprisingly I made progress fast and it was running well on Linux and Windows until I hit the part where I am doing my
HttpWebRequest.

The website I pull from is ancient, written in Perl CGI with some javascript and probably Java. Basically I push back a lot of Content-Disposition: form-data; with logins and keys with the credentials. I then look for a key= and a random number which represents the cookie data. I then store that cookie data and it persist so I can navigate to the page containing the data. Unfortunately I can post very little of the code, mainly because of the nature of the job. I can probably change some of the code and post bits and pieces if needed, changing when necessary. The thing is the current code running on Windows in .NET CORE runs perfectly, but if I upload it to Debian or Raspbian, it does not run properly and the returned data is way incorrect. Could it be what the Linux .DOTNET core is using to do the post request?


#2

I think there is not enough information here to say what the issue is. In what way is the returned data incorrect? Could you capture a successful request and an unsuccessful one using a tool like Wireshark and compare the two?

Also, this forum is not very active, you have a better chance of getting a good answer if you create an issue about this in the corefx repo, which is where the code for the .Net Core version of HttpWebRequest is.


#3

I tried it with Python and had something going in about two hours, I think I am going to go that route. This will help me learn another language anyway, and that never hurts.


#4

Did you try using Fiddler to inspect the initial request? Whenever I run into a network issue, Fiddler is the tool I open first. If you dump the HTTP request to plain text, it should be easy to see the byte difference between the old request and the new request.

The only other thing I can think of causing a difference is the TLS version, or something TCP-specific like timing or connections…


.NET Foundation Website | Blog | Projects | Code of Conduct