Home » c# » google chrome – Need some advice on session specific cookies for C# Http client code-Exceptionshub

google chrome – Need some advice on session specific cookies for C# Http client code-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I need some advices. I have to C# Httpclient to post some data in a web server, the web page uses tons of JavaScript, some of the JavaScript set cookies in browser. I can always submit a form by clicking on the buttons from the web page; however, in order to automate the job, I have to use C# Httpclient. When I use Chrome Developer tools to look the Network requests, I found nearly 60 cookies (name value pairs), now I can use a text browser to get some cookies, but not all of them. However, some cookies are not useful for posting data, which obvious from the cookies’ name. But some cookies is not easy to get by the text browser; but I can’t use a graphic or GUI browser, due to the performance issue.
I tried some time using C# Httpclient to post data, but I always got 500 internal error. I suspect it is due to missing cookies, I can use Text browser to get nearly 90% of all the cookies; but nearly 5 of the session specific cookies are missing. I want to know, since not all the cookies are necessary for posting data; I want to know if there is any tools to find which cookies are necessary for HTTP post request? Some cookies can be easily added as their name and values are fixed, but some cookies are obviously session specific, like: jessionid=12345; since I can’t use text browser to get this kind of session specific cookies, since the text browser doesn’t run JavaScript.

I need some advice how to fix the issue: find which cookies are necessary and/or how to create a missing session specific cookies, like: jessionid=12345; if such cookies are not necessary, or I can cheat the web server with a random value for jessionid, then I can easily create a cookies with a random value to post the data to web server.
Please advice or tell me if my thinking is right or wrong.

How to&Answers: