I searched and read about it, and could not distinguish anything.
I am writing a small search application in C # that allows you to send files to a web server, not via FTP, but through HTTP using POST. Think of it as a web form, but work in a Windows application.
I have an HttpWebRequest object created using something like this
HttpWebRequest req = WebRequest.Create(uri) as HttpWebRequest
and set the Method , ContentType and ContentLength . But this is far I can go.
This is my piece of code:
HttpWebRequest req = WebRequest.Create(uri) as HttpWebRequest; req.KeepAlive = false; req.Method = "POST"; req.Credentials = new NetworkCredential(user.UserName, user.UserPassword); req.PreAuthenticate = true; req.ContentType = file.ContentType; req.ContentLength = file.Length; HttpWebResponse response = null; try { response = req.GetResponse() as HttpWebResponse; } catch (Exception e) { }
So my question basically is how can I send fie (text file, image, audio, etc.) using C # via HTTP POST.
Thank!
gabitoju Jul 15 '09 at 13:31 2009-07-15 13:31
source share