HttpPostedFile.SaveAs

A

Al Smith

Hi,

I am able to use the HttpPostedFile.SaveAs() method to upload and save a
file to the local web machine. However, I would really like to save the
file to a VirtualDirectory.

Does anyone know if this can be done and the syntax to do it?

Thanks

Al
 
K

Kevin Spencer

Files are not stored in virtual directories. Virtual Directories are part of
the web server configuration, and correspond to file system directories. You
save files to file system directories. If you want to save a file to a
virtual directory, save it to the file system directory which that virtual
directory is mapped to.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
K

Kody Brown

You can open the IIS meta-data to find out the physical location of the
virtual directory, then save to that.
 
A

Al Smith

How is security applied then? The aspx user (local machine) then needs
access to a different machine on the network where the VD resides. That is
why I was hoping a VD could be used since access to the VD is associated
with a network user.

Thanks
 
K

Kevin Spencer

Virtual Directories, like file system directories, have security, albeit
somewhat different kinds. However, a virtual directory is not associated
with a network user any more than a file system directory is. Each has any
number of authorized users associated with it. However, this is not the
issue. The issue is what account is trying to write the file, and that is
the account under which ASP.Net is running, in both circumstances.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
A

Al Smith

Thanks for the feedback Cody. The problem has been access to a network
machine from the anonymous access account. Thus I was hoping the
VirtualDirectory could somehow be used in reverse so to say (using the user
associated with it) which is not the case. So finding the physical location
is not really the issue, accessing it anonymously is.

Since we have components running as a network user, we used them to provide
the functionality needed.

Thanks
 
S

Steven Cheng[MSFT]

Hi Al,

Yes, the critical problem is that when accessing a remote shared folder( or
event a local folder), the asp.net application may haven't sufficient
permission. And generally anonymous access is not suitable since that
require the folder be configured as everyone accessable. I think one means
is to grant the folder's required permissions to a certain account(Domain
account or a duplicated local account which has identical username and
password on two machines), then we need to impersonate the asp.net context
when we need to do file operations in the folder. Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top