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?

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
CharlieT
  • 373
  • 4
  • 26
  • 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? – ProgrammingLlama Oct 24 '22 at 14:59
  • 1
    https://stackoverflow.com/a/4015346/12473121 Method C is what you are looking for – radoslawik Oct 24 '22 at 15:08
  • I think your problem will be solved by looking here: [Setting a WebRequest's body data](https://stackoverflow.com/a/4256187/6300534) – Seyyed M.H Mousavi Oct 24 '22 at 15:12
  • Logging is up to the server to worry about, not the client. `HttpWebRequest` is basically deprecated, consider moving to `HttpClient` – Charlieface Oct 24 '22 at 21:15

0 Answers0