我有一個Web服務的兩種方法,我試圖用Web客戶端調用:WebClient的UploadString不工作
[Route("TestDownload")]
[HttpGet]
public string TestDownload()
{
return "downloaded";
}
[Route("TestUpload")]
[HttpPost]
public string TestUpload(string uploaded)
{
return uploaded;
}
此代碼:
using (var wc = new WebClient())
{
var sResult = wc.DownloadString("http://localhost/Website/TestDownload");
Console.WriteLine(sResult);
}
此代碼拋出一個System.Net。 WebException:(404)Not Found
using (var wc = new WebClient())
{
var sResult = wc.UploadString("http://localhost/Website/TestUpload", "test");
Console.WriteLine(sResult);
}
我在做什麼錯?由於
嗯所以我把它這個參數放在URL字符串中。如果字符串太大而不適合(它實際上是一個序列化對象)呢? –