我编写了一个asp.net web API,它在控制器中有一个文件阅读器/解析器。当我通过Visual Studio环境运行时,我能够很好地访问网络上的文件(Z:\ TestFile.txt)。但是,当我从我的localhost IIS 7.5运行时,我得到无法找到路径'Z:\ TestFile.txt'的一部分。
我很确定这是某种许可问题。为了确认这一点,我能够从Visual Studio IIS Express和我的localhost IIS 7.5轻松地从本地C读取文件。
为什么我能够通过Visual Studio IIS Express获得成功,但不能通过IIS 7.5获得成功。我在Windows 7机器上运行。我已配置我的ASP.NET 4.0应用程序池以允许模拟,并模拟我的凭据。带有IIS的Windows 7是否可能不允许模拟通过?
我的web.config文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings />
<system.web>
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5" requestPathInvalidCharacters="" />
<identity impersonate="true" userName="MyDomain\MyUserID" password="MyPassword"/>
</system.web>
<system.webServer>
<handlers>
<add name="ApiURIs-ISAPI-Integrated-4.0" path="/ReadFile/*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>