webclient服务端代码是不需要的,iis就是服务端,手机打字,很慢,
webclient test=new webclient()Test.credentials=new. Networkcredential(username,pass)
Client.uploadfile(服务器地址+文件名,‘put’,文件的绝对路径)
手机不方便,请见谅,说明一下,代码很简单,主要是iis的配置,另外,上传程序在iis6上运行成功,iis7.5上有一次诡异的成功经历,之后一直出现405。

解决方案 »

  1.   

    成功的那次,我用的是webdav+windows身份验证,其他的我感觉也没弄,就可以上传成功,后来我以为是文件夹权限问题,我用那个成功的网站随便指向一个新建的文件夹,也ok,但是按照之前的方法新建网站就不行,活见鬼一样。
      

  2.   

    try this
    IIS7.5上的REST服务的Put操作发生HTTP Error 405.0 - Method Not Allowed 解决方法
    http://www.cnblogs.com/shanyou/archive/2012/03/23/2414252.html
      

  3.   

    刚才那个链接下边是英文原版链接,看看有没有用,还有回复内容中有描述也。
    http://brockallen.com/2012/10/18/cors-iis-and-webdav/
      

  4.   

    [quote=引用 It’s working now with the config from my screen shot. Although I might try your config. At this point I’m really just trying to understand it better.
    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).
      

  5.   

    runallmanagedmodulesforallrequests=true这是什么意思?
      

  6.   

    ·405 - 用来访问本页面的 HTTP 谓词不被允许(方法不被允许) 
      

  7.   

    感觉你写的有问题
    Client.uploadfile(服务器地址+文件名,‘put’,文件的绝对路径)
    第一个参数是接受文件的Uri,
      

  8.   

      UploadFile(String, String)  将指定的本地文件上载到具有指定 URI 的资源。  
      UploadFile(Uri, String)  将指定的本地文件上载到具有指定 URI 的资源。  
      UploadFile(String, String, String)  使用指定的方法将指定的本地文件上载到指定的资源。  
      UploadFile(Uri, String, String)  使用指定的方法将指定的本地文件上载到指定的资源。  
      

  9.   

    WebClient.UploadFile 方法 (String, String, String) Visual Studio 2013Visual Studio 2013 本文内容已由机器翻译。如果您连接了 Internet,请选择“联机查看本主题”以在可编辑模式下对照英文内容查看此页。
    向 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
    要发送到资源的文件。 
      

  10.   

    MSDN 上已经说的很清楚了
    address 
    类型: System.String
    接收文件的资源的 URI。  
    //第一个参数 代表接受文件的地址
      

  11.   

    感觉你写的有问题
    Client.uploadfile(服务器地址+文件名,‘put’,文件的绝对路径)
    第一个参数是接受文件的Uri, 
    我用字符串表达有错??
    算了,我问的不是函数表达式,我问的是如何解决405,你的解答和我问的无关
      

  12.   

    如果你说的是用URI,我刚刚试过,依然405,如果你说的是别的意思的话,请指教。