2010-12-31 7 views
1

私はこの試みた:C#の - 教え新しいスレッド

public static void CreateNewThread(string url,string fId, string title, string message, string tag) 
{ 
    url += "newthread.php?do=postthread"; 

    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); 
    //string result = ""; 

    string values = "subject=" + title 
        + "&message=" + message 
        + "&tag=" + tag 
        + "&do=postthread" 
        + "&f=" + fId 
        + "&s=" 
        + "" 
        ; 

    req.Method = "POST"; 
    req.ContentType = "application/x-www-form-urlencoded"; 
    req.ContentLength = values.Length; 

    ServicePointManager.Expect100Continue = false; // prevents 417 error 

    using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), Encoding.UTF8)) 
    { 
     writer.Write(values); 
    } 

    HttpWebResponse c = (HttpWebResponse)req.GetResponse(); 
} 

をしかし、これはdoesntの仕事です!

+0

「これは動作しません」何が起こっているかの良い十分な説明ではありませんHTTPをお読みください:// tinyurl.com/so-hints –

+0

"動作しません!" - エラーメッセージに表示されているのは? – Juliet

答えて

1

件名とメッセージPARAMATERSをコードしてみてください。

HttpUtility.UrlEncode(

string values = "subject=" + HttpUtility.UrlEncode(title) 
        + "&message=" + HttpUtility.UrlEncode(message) 
        + "&tag=" + HttpUtility.UrlEncode(tag) 
        + "&do=postthread" 
        + "&f=" + fId 
        + "&s=" 
        + "" 
        ; 
関連する問題