Hi,
Does any one know, how to communicate to Apache server from client side using Win32 or C#. and can i get the control to execute the process at server? if so how to do?. how to receive file sent by apache?.
Please help me...
Thanks
Hi,
Does any one know, how to communicate to Apache server from client side using Win32 or C#. and can i get the control to execute the process at server? if so how to do?. how to receive file sent by apache?.
Please help me...
Thanks
You can use HTTPWebRequest and HTTPWebResponse to make a request to a web server and receive a response.
For example
static void Main(string[] args)
{
// used to build entire input
StringBuilder sb = new StringBuilder();
// used on each read operation
byte[] buf = new byte[8192];
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://www.mayosoftware.com");
// execute the request
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
// we will read data via the response stream
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
// fill the buffer with data
count = resStream.Read(buf, 0, buf.Length);
// make sure we read some data
if (count != 0)
{
// translate from bytes to ASCII text.
// Not needed if you'll get binary content.
tempString = Encoding.ASCII.GetString(buf, 0, count);
// continue building the string
sb.Append(tempString);
}
}
while (count > 0); // any more data to read?
// print out page source
Console.WriteLine(sb.ToString());
}
Okay. Assuming you are talking about "Apache httpd", then we are talking about a server which talks HTTP
. Pretty much any programming language has some "HTTP Client" classes. In the case of C#, you can use HttpWebRequest. Vinko gave a great "copy/paste" example.
To run a process on the server-side, you need some "server side scripting". If there is no module available for the httpd server, then you can always resort to CGI
. This is potentially dangerous, if not careful though. But you can say this about all server-side scripting (the "if not careful" is important here).
As it sounds like, you are new to dynamic web development. And, as much as I dislike it, I have to say that the PHP community is a great starting point.
To give a rough overview of how things work:
HTTP GET
command and decides what to do with it.What I understood the least when I got started were the "cryptic" httpd-configurations. They are simple to understand though. They are there to tell the server how (and what) to map to the external process (as noted in step 4a and 4b).
So, in the case of PHP:
LoadModule php5_module modules/libphp5.so
This makes the "external process" and configuarion directives available to the server (loads the extensions).
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
The default Apache-httpd handler assumes that a URL maps to a File on the file system. This configuration directive tells httpd to process (handle) each filename ending with ".php" using the PHP module before returning it to the client.
These steps are very similar for other server-side applications. I only gave PHP as a practical example. And it's got very good documentation.