webclient服务端代码是不需要的,iis就是服务端,手机打字,很慢,
webclient test=new webclient()Test.credentials=new. Networkcredential(username,pass)
Client.uploadfile(服务器地址+文件名,‘put’,文件的绝对路径)
手机不方便,请见谅,说明一下,代码很简单,主要是iis的配置,另外,上传程序在iis6上运行成功,iis7.5上有一次诡异的成功经历,之后一直出现405。
webclient test=new webclient()Test.credentials=new. Networkcredential(username,pass)
Client.uploadfile(服务器地址+文件名,‘put’,文件的绝对路径)
手机不方便,请见谅,说明一下,代码很简单,主要是iis的配置,另外,上传程序在iis6上运行成功,iis7.5上有一次诡异的成功经历,之后一直出现405。
IIS7.5上的REST服务的Put操作发生HTTP Error 405.0 - Method Not Allowed 解决方法
http://www.cnblogs.com/shanyou/archive/2012/03/23/2414252.html
http://brockallen.com/2012/10/18/cors-iis-and-webdav/
At first I just had the WebDav Module removed. This only worked in IIS8. In IIS 7.5 something was still handing the “OPTIONS” verb and it would get no where near my custom handler or your IdentityModel Cors handler.
To get it work in IIS 7.5 I did as follows:
a) Removing the WebDav module.
b) set runAllManagedModulesForAllRequests = true.
(I did not have WebDAV handler removed as in your example above, but I would like to try that).
Client.uploadfile(服务器地址+文件名,‘put’,文件的绝对路径)
第一个参数是接受文件的Uri,
UploadFile(Uri, String) 将指定的本地文件上载到具有指定 URI 的资源。
UploadFile(String, String, String) 使用指定的方法将指定的本地文件上载到指定的资源。
UploadFile(Uri, String, String) 使用指定的方法将指定的本地文件上载到指定的资源。
向 Microsoft 发送有关本主题的反馈。 联机在默认浏览器中联机查看本主题。
使用指定的方法将指定的本地文件上载到指定的资源。
命名空间: System.Net
程序集:System(在 System.dll 中)
语法
--------------------------------------------------------------------------------JavaScriptC#C++F#JScriptVB以带有颜色区分的格式查看复制到剪贴板public byte[] UploadFile(
string address,
string method,
string fileName
)public byte[] UploadFile(
string address,
string method,
string fileName
)
public:
array<unsigned char>^ UploadFile(
String^ address,
String^ method,
String^ fileName
)public:
array<unsigned char>^ UploadFile(
String^ address,
String^ method,
String^ fileName
)
member UploadFile :
address:string *
method:string *
fileName:string -> byte[]member UploadFile :
address:string *
method:string *
fileName:string -> byte[]
'声明
Public Function UploadFile ( _
address As String, _
method As String, _
fileName As String _
) As Byte()'声明
Public Function UploadFile ( _
address As String, _
method As String, _
fileName As String _
) As Byte()参数
address
类型: System.String
接收文件的资源的 URI。 method
类型: System.String
使用的方法会将文件发送到资源。 如果 null,默认值为HTTP和STOR的文章FTP的。fileName
类型: System.String
要发送到资源的文件。
address
类型: System.String
接收文件的资源的 URI。
//第一个参数 代表接受文件的地址
Client.uploadfile(服务器地址+文件名,‘put’,文件的绝对路径)
第一个参数是接受文件的Uri,
我用字符串表达有错??
算了,我问的不是函数表达式,我问的是如何解决405,你的解答和我问的无关