VS C# 2005
我使用下面的代码将文件上传到运行Windows IIS 5.1的服务器。使用webclient上传文件405错误问题
我只是在运行Windows XP的本地服务器上进行测试。但是,我不断收到以下错误消息:
The remote server returned an error (405) Method Not Allowed
我确定这是一个IIS问题,也许是有权限的东西。但是,我配置了IIS以允许读取,写入和目录浏览。
我想上传的config.xml文件与可执行文件位于同一目录中。
private void upload_config_to_server()
{
Uri url = new Uri("http://10.10.10.3/softphone/config.xml");
WebClient wc = new WebClient();
if (!wc.IsBusy)
{
try
{
wc.UploadFile(url, null, "config.xml");
}
catch (WebException webex)
{
Console.WriteLine("Web Exception {0}", webex.Message);
}
catch (Exception ex)
{
Console.WriteLine("Exception {0}", ex.Message);
}
}
}
非常感谢您的任何建议,
2011-03-02
ant2009