代码之家  ›  专栏  ›  技术社区  ›  NandoAndes

IIS/.NET从共享网络驱动器打开/下载文件

  •  0
  • NandoAndes  · 技术社区  · 4 年前

    IIS 10在使用C时遇到问题,尝试下载位于共享网络驱动器中的文件。

        <preConditions>
          <preCondition name="Excel Example">
            <add input="{HTTP_USER_AGENT}" pattern="Trident" negate="true" />
          </preCondition>
        </preConditions>
    
       <!-- Sample rules -->
       <rule name="test excel" enabled="true" stopProcessing="true">
          <match url=".*.xlsx" />
          <action type="Rewrite" url="site/{R:0}" />
        </rule>
    
        <rule name="File Downloads" enabled="true" stopProcessing="true">
          <match url=".*netdrive(.*)" />
          <action type="Rewrite" url="site/{R:3}" />
        </rule>
    

    甚至出站规则:

        <rule name="Allow xlsx to be downloaded" preCondition="Excel Example">
          <match serverVariable="RESPONSE_Content_Disposition" pattern=".*netdrive(.*)" negate="false" />
          <action type="Rewrite" value="https://samplesite.org/netdrive/{R:1}" />
        </rule>
    
        <rule name="Allow xlsx to be downloaded2" preCondition="Excel Example">
          <match serverVariable="RESPONSE_Content_Disposition" pattern=".*[\/\\]netdrive[\/\\](.*)" negate="false" />
          <action type="Rewrite" value="https://samplesite.org/netdrive/{R:1}" />
        </rule>
    

    从字面上看,在.xlsx文件上没有匹配项。我得到404,最多是http://,但只有404屏幕。。。

    Requested URL      http://localhost:80/netdrive/Subfolder1/File.xlsx
    
    Physical Path      C:\inetpub\wwwroot\netdrive\Subfolder1\File.xlsx
    

    0 回复  |  直到 4 年前