【发布时间】:2016-05-09 11:56:32
【问题描述】:
WinForm 应用程序代码-
FileSystemWatcher fsWatcher = new FileSystemWatcher();
fsWatcher.Created += new FileSystemEventHandler(OnCreated);
public void OnCreated(object sender, FileSystemEventArgs e)
{
try
{
var wc = new WebClient();
byte[] response =
wc.UploadFile("http://localhost:54802/Home/ReceiveAudio/",
"POST", e.FullPath);
string s = System.Text.Encoding.ASCII.GetString(response);
MessageBox.Show(s);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
MVC 控制器动作方法-
[HttpPost]
public JsonResult ReceiveAudio()
{
return Json("Success", JsonRequestBehavior.AllowGet);
}
我收到错误 -An exception occurred during a WebClient request.
有什么帮助吗?
【问题讨论】:
-
你为什么在 post 请求中使用
JsonRequestBehavior.AllowGet?
标签: c# asp.net-mvc winforms file-upload webclient