File Upload to different server

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to upload a file to a different server other than the one
hosting the web app? I've tried using the following syntax:

Request.Files.SaveAs("\\\\servername\\sharename\\directory" + strFileName);

but receive the message that the location cannot be found. The Windows
account it is running under has full permissions to this directory.

Thanks!
 
Are you sure that you have impersonation set up correctly to run under
this account? ASP.NET doesn't run under the account set up in IIS config,
but rather, what you set up in the web.config file for the application, or
the ASPNET by default.

Hope this helps.
 
mt,

If you have the authentication set to Windows, then it will use windows
to authenticate the user. However, it will still run under the ASPNET local
account. You have to set impersonation to true, through the <identity> tag
in web.config:

<identity impersonate="true"/>

This will have the thread doing the processing run as the Windows user
account that you logged in as. Be careful though, as you are elevating the
permissions of all code that runs under that request, which is generally a
bad thing.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mt said:
Thanks Nicholas. I assume from your reply that what I'm trying to do
really
is possible, I just need to track down the problem...? In the web.config
file the Authentication Mode is set to Windows. Impersonation is not set
up.
If I understand correctly, when I run the application, it should run under
my user account, which is an administrator on both the web server and the
other server where I want to copy the file. Any ideas?

Nicholas Paldino said:
Are you sure that you have impersonation set up correctly to run
under
this account? ASP.NET doesn't run under the account set up in IIS
config,
but rather, what you set up in the web.config file for the application,
or
the ASPNET by default.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mt said:
Is there a way to upload a file to a different server other than the
one
hosting the web app? I've tried using the following syntax:

Request.Files.SaveAs("\\\\servername\\sharename\\directory" +
strFileName);

but receive the message that the location cannot be found. The Windows
account it is running under has full permissions to this directory.

Thanks!

 
Back
Top