(I'm a beginner. This is to understand PHP better.)
While experimenting with HTTP I was trying to GET
a PHP-file from my server and I didn't get anything. Neither the HTTP-Header Content-Length
nor any content is available for reading in the response.
string url = "http://php.net/sites.php";
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.AutomaticDecompression = DecompressionMethods.GZip;
request.Method = "GET";
Stream stream = request.GetRequestStream(); // "ProtocolViolationException" is thrown here
StreamWriter writer = new StreamWriter(stream);
writer.WriteLine("test 3");
So with that C# code above and with my local IIS i can't GET any php files right? I can GET only html, js, css, images and a few_other right? What I found out as well is if I want the PHP script to be executed I need to change "GET" to "POST" and then I will be getting the PHP output.
What I would like to understand:
- There is no way for me with common Web-Servers to retrieve PHP code?
- Webbrowsers do POST-requests automatically when retrieving php output?
- Why is it like this?
FYI: (not important here) I have to write C# app later that is going to communicate to a WebServer to retrieve some data and do actions that Webbrowsers can't do.