0

I right now have an HTTP POST request using this layout:

private static readonly HttpClient client = new HttpClient();

var values = new Dictionary<string, string>
{
   { "thing1", "hello" },
   { "thing2", "world" }
};

var content = new FormUrlEncodedContent(values);

var response = await client.PostAsync("https://www.example.com/recepticle.aspx", content); //It's not the URL I'm using.

var responseString = await response.Content.ReadAsStringAsync();

I want to set a password(textbox) on a website using a POST request with C#. I tried with the above layout, but it doesn't set it. So I think it's because I'm using an HTTP request instead of an HTTPS request(Do you think I'm right?). My problem is, I don't know how to send it as an HTTPS request. I need a way to make it HTTPS.

I should probably clarify that I'm sending the following things:

Password, - Not in the textbox
Password again, - Not in the textbox 
question index, - In the textbox
answer for the question, - In the textbox
terms_of_service. - Not in the textbox

So I guess the website does process my request but doesn't care about some things in it. Maybe it's the cookies?

Thank you in advance.

Flafy
  • 176
  • 1
  • 3
  • 15
  • Just add an `s` after the `http`, HttpClient will take care of the rest. – Washington A. Ramos Feb 18 '20 at 20:26
  • @WashingtonA.Ramos I'm sorry, the URL I'm working with does start with HTTPS and I did mention it in my code. Still doesn't work. – Flafy Feb 18 '20 at 20:29
  • What is the status code of response and the response content? – Chetan Feb 18 '20 at 20:34
  • 1
    This is unlikely to do with HTTPS. If you're trying to POST to a WebForms page (assumption made from the .aspx), you need to include valid __VIEWSTATE and __EVENTVALIDATION values, usually obtained from a GET. A CSRF token may also be required. You would then need to set the control source for the postback to the correct unique identifier for the normal login button, as well as send the username and password as values for the unique identifiers of the username and password text boxes. – Jonathon Chase Feb 18 '20 at 20:34
  • Does this answer your question? [Make Https call using HttpClient](https://stackoverflow.com/questions/22251689/make-https-call-using-httpclient) – Washington A. Ramos Feb 18 '20 at 20:36
  • @JonathonChase . I don't think this is the case. The URL in the code is just an example URL. The URL I'm using doesn't have a ".aspx". Also, I should probably clarify that I'm sending the following things: Password, Password again, question index, answer for the question, terms_of_service. From all of these, I can only see the question index and the answer on the page. So the website does process my request but doesn't care about some things in it. Maybe the cookies? – Flafy Feb 19 '20 at 05:06

1 Answers1

0

Apperantly the website did process and got the things I sent him but it never sent them back to me, because security.

Flafy
  • 176
  • 1
  • 3
  • 15