IIS Virtual Directory map to network drive (with drive letter) but fail to create file

时间秒杀一切 提交于 2019-12-18 03:39:38

问题


I am using C#/ASP.NET, IIS6 on Windows Server 2003.

  1. Map the data server shared folder to the WebServer with driver letter V:\

  2. On the WebServer, IIS created a virtual directory and pointed to 'local location' with V:\ . Since there is no 'Connect As', not sure which USER will be used

  3. In my WebMethod, I want to create file on the shared folder with FileStream.Write().

    I got IO Exception on the action, any hint?

P.S. I have added ASPNET/NETWORK SERVICE on the data server shared folder.

thanks! Gavin


回答1:


Mapped network drives are specific to the user account that created them:

Using Mapped Drives with IIS - MS KB257174

The preferred method of accessing content for the Web server that exists on a remote computer is to use shares that follow the universal naming convention (UNC).

It's very likely that NETWORK SERVICE (or if you're running ASP.NET under impersonation, the site anonymous account) hasn't got this mapping.

To change the location where the virtual directory points to, browse to your site in IIS manager, right click on the virtual directory and select properties. You can then select "A share located on another computer":




回答2:


The website in IIS has a corresponding app pool and this should tell you the user under which your code wil be running. You'll the have to grant the appropriate permissions for that share for that user.



来源:https://stackoverflow.com/questions/4497131/iis-virtual-directory-map-to-network-drive-with-drive-letter-but-fail-to-creat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!