1

I have to manage the attachment in a file server. So I mapped the file server to local e: driver, and point to it directly in my program. It works fine in my working machine, but reports can not find path in the application server where I put my code on. Does anyone knows how to map a path in remote server? It's a .net project, and I use c#. Thanks in advance.

Steven Zack
  • 4,984
  • 19
  • 57
  • 88

1 Answers1

0

Drive mappings are on a per-user basis. My guess is that you are using the built-in development server when developing your ASP.NET application.

This server runs under your own account, which is why you can see drive mappings associated with your account. However, when run in IIS, it runs under another user (more than likely the ASP.NET local user for running ASP.NET applications, unless specified otherwise).

That said, you should be using UNC paths to find your files and not rely on mapped drives; these names will always be the same.

Even if you set the drive mappings up for the ASP.NET user, you have a problem if you impersonate the user, so best to stick with the UNC paths.

casperOne
  • 73,706
  • 19
  • 184
  • 253
  • when I use UNC, it comes out with an error message states that "Logon failure: unknown user name or bad password". Do you know the reason? – Steven Zack May 02 '11 at 18:45
  • @Steven Zack: Yes, it's because the *local* ASP.NET account doesn't have access to network resources. You should either set the network resource's permissions to allow the ASP.NET user to access the resource, or (even better), create a network user that the ASP.NET application runs under (instead of the default) and assign access t that user. – casperOne May 02 '11 at 18:50
  • The folder could be accessed by everyone. Do I have to do something on my code? – Steven Zack May 02 '11 at 19:10
  • @Steven Zack: No, this is a config setting; look at the `` tag for `web.config` files. – casperOne May 02 '11 at 19:32
  • @casperOne, sorry, but could you explain with more details? What should I do to web.config? Thanks in advance. – Steven Zack May 02 '11 at 22:20
  • @Steven Zack: [ASP.NET Impersonation](http://msdn.microsoft.com/en-us/library/aa292118(v=vs.71).aspx) – casperOne May 02 '11 at 23:54