1

I am a PHP developer doing a C# project

I have a C# winform project where the end user login to the software.

The login goes through a HttpWebRequest

 var user = txtuser.Text; var pass = txtpass.Text; var url = "https://www.example.com/directory/directory.php?"; var var = "user=" + user + "&pass=" + pass; var URL = url + var; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. var responseFromServer = reader.ReadToEnd(); // Display the content. if (responseFromServer.Contains("Access") == true) { Thread.Sleep(4000); IsLoginTrue = true; 

The connection is secured, but I am concerned about security because GET request are logged in plain text web logs.

Can I do an HttpWebRequest with a POST method?

4
  • That's a perfectly common scenario (sending data in a post request), so yes you can do it. Do you want to try this question again to be a bit more precise about the problem you're seeing? Commented Oct 24, 2022 at 14:59
  • 1
    stackoverflow.com/a/4015346/12473121 Method C is what you are looking for Commented Oct 24, 2022 at 15:08
  • I think your problem will be solved by looking here: Setting a WebRequest's body data Commented Oct 24, 2022 at 15:12
  • Logging is up to the server to worry about, not the client. HttpWebRequest is basically deprecated, consider moving to HttpClient Commented Oct 24, 2022 at 21:15

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.