2

I am working on a C# project. The problem is:

When program is making a post request no cookies are being sent to server. But actually, cookies are showing on browser. Because of this, program is returning back to home page and then then I redirect it to postdata method again where I am posting the data. This time I am getting correct data and cookies also present in cookie container.

I do not understand what is the problem and why post request does not accept any cookies at first attempt.

Abhishek
  • 2,925
  • 4
  • 34
  • 59
  • If any arbitrary .NET program could get at your browser cookies, that would be a bit of a security vulnerability, IMO... – Jon Skeet Jul 27 '15 at 06:23
  • then what is the solution to solve this problem.in browser session id is constant for each request but in program it is changing every time.i am tracking this coockie or session id in previous method and trying to send it externaly through coockiecontainer but it is not accepting – abhinaya balol Jul 27 '15 at 06:34
  • 1
    Firstly, it's worth knowing that it's "cookie" not "coockie" - it'll make it easier to find results when looking for problems if you use the right spelling. (This isn't a criticism - just trying to help.) Now, leaving the "I can't get cookies out of the browser" part aside, if you're having problems with *just* the C# code, I suggest you post a short but complete program demonstrating your problem and describe clearly what you're seeing vs what you expected. – Jon Skeet Jul 27 '15 at 06:44
  • I don't know which class are you using to make HTTP requests.But if you are using WebClient then CookieContainer doesn't work out of box and you have to configure it /extend the WebClient to persist cookies between the requests https://stackoverflow.com/questions/1777221/using-cookiecontainer-with-webclient-class – Vojtech B Jul 27 '15 at 07:06

0 Answers0