Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 914
Gavin Avatar asked Dec 21 '10 07:12

Gavin


People also ask

How do I map a network drive into a letter?

Open File Explorer from the taskbar or the Start menu, or press the Windows logo key + E. Select This PC from the left pane. Then, on the File Explorer ribbon, select More > Map network drive. In the Drive list, select a drive letter.

Why can't I map a network drive?

If Windows can't map your network drive, update your computer, and disconnect all peripherals. Additionally, give everyone access rights to the folder you want to share. Then enable file sharing support for Client and Server. If the issue persists, tweak your Registry Editor and set ProviderFlags value data to 1.


1 Answers

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

like image 103
Kev Avatar answered Nov 09 '22 07:11

Kev