9

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

Community
  • 1
  • 1
Gavin
  • 91
  • 1
  • 1
  • 3

2 Answers2

11

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":

alt text

Community
  • 1
  • 1
Kev
  • 118,037
  • 53
  • 300
  • 385
0

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.

Matt
  • 25,943
  • 66
  • 198
  • 303
  • NETWORK SERVICE is the user running the app pool. I have added this user on the shared folder (a remote machine). But still encountered the issue. – Gavin Dec 21 '10 at 08:17