|
|
|
HttpWebRequest - отправка POST запроса
|
|||
|---|---|---|---|
|
#18+
Добрый день! Пытаюсь отправить содержимое файла (не сам файл, а именно содержимое), но до сервера оно не доходит.. public void SendPOST() { string url = t_ScriptURL.Text; string boundary = "---------------------------114782935826962"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = @"text/xml;charset=""utf-8"""; request.Method = "POST"; request.KeepAlive = true; request.ContentType = "multipart/form-data; boundary=" + boundary; System.Text.StringBuilder header = new StringBuilder(); header.AppendLine(boundary); header.AppendLine("Content-Disposition: form-data; name=\"encoding\""); //header.AppendLine("application/octet-stream"); header.AppendLine(); header.AppendLine("asdfghyujio;luikyjthrgfrtyuiopo/.uik,mtyhbrgtffrghnymjuik,ol."); header.AppendLine(boundary); StreamWriter HeaderDoc = new StreamWriter("header.txt"); HeaderDoc.WriteLine(header.ToString()); HeaderDoc.Close(); MessageBox.Show("OK"); byte[] message = Encoding.UTF8.GetBytes(header.ToString()); request.ContentLength = header.Length; using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(message, 0, message.Length); requestStream.Close(); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader sr = new StreamReader(response.GetResponseStream())) { string responseString = sr.ReadToEnd(); StreamWriter ResultDoc = new StreamWriter("FileResult.txt"); ResultDoc.WriteLine(responseString); ResultDoc.Close(); MessageBox.Show("OK"); } Тело запроса получается таким: ---------------------------114782935826962 Content-Disposition: form-data; name="encoding" asdfghyujio;luikyjthrgfrtyuiopo/.uik,mtyhbrgtffrghnymjuik,ol. ---------------------------114782935826962 Но до сервера переменная encoding не доходит ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 20.07.2012, 12:11 |
|
||
|
HttpWebRequest - отправка POST запроса
|
|||
|---|---|---|---|
|
#18+
Я полагаю, что вопрос надо перенести в ASP.Net Сообщил модераторам Модератор: Тема перенесена из форума "WinForms, .Net Framework". ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 20.07.2012, 20:34 |
|
||
|
HttpWebRequest - отправка POST запроса
|
|||
|---|---|---|---|
|
#18+
нееет. Я отправляю запрос из win-Form скрипту, работающему на php. ASP здесь совершенно не причем. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 20.07.2012, 21:32 |
|
||
|
|

start [/forum/topic.php?fid=18&fpage=124&tid=1359391]: |
0ms |
get settings: |
7ms |
get forum list: |
10ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
70ms |
get topic data: |
7ms |
get forum data: |
2ms |
get page messages: |
26ms |
get tp. blocked users: |
1ms |
| others: | 229ms |
| total: | 356ms |

| 0 / 0 |
