Solved

Upload File to Mapped Drive

Posted on 2004-09-14
6
485 Views
Last Modified: 2008-02-01
I have Web Application on Machine A which will upload all the files to shared folder (Machine B) which is mapped drive (P:\) on Machine A.
This error occured when i try to upload file..

--------------------------------------------------------------------------------------------------------------------------------------------------------
Could not find a part of the path "P:\0000000127.swf".
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path "P:\0000000127.swf".
---------------------------------------------------------------------------------------------------------------------------------------------------------

Please advise. Thanks.
0
Comment
Question by:ztot
  • 3
  • 3
6 Comments
 
LVL 10

Expert Comment

by:jnhorst
ID: 12061661
Using mapped drives in ASP.NET is a hit and miss proposition.  Use a UNC path instead:  \\ServerName\ShareName\Folder\file.ext

John
0
 

Author Comment

by:ztot
ID: 12061970
John, i had try ur method, but now i encounter another problem as stated below:
Logon failure: unknown user name or bad password.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.IOException: Logon failure: unknown user name or bad password.
0
 
LVL 10

Accepted Solution

by:
jnhorst earned 50 total points
ID: 12068206
Here's what is going on: When you access a website or sweb service, if you are not required to enter a username and password, the web server is accepting your request as an anonymous user.  If you go to the IIS settings on the web server and look under Directory Security there is a button for editing authentication settings for anonymous users.  By default your web server will use an account named IUSR_<machine name>.  Your web server will also have an account named ASPNET.  Both of these accounts are local to that machine.  You have the server on which the file exists (the one named in your UNC path).  That server knows nothing about the local accounts on your web server, so it will not allow the access.

In you look in your web.config and you do not have the following:

<identity impersonate="true" />

then your web server is using its local ASPNET account when it executes ASP.NET code.  If you do have this, or you put it in (I recommend doing so) then your web server will use the IUSR_... account specified in the IIS settings to execute code.

So what you want to do is this: Create a domain or Active Directory account on your network that will be used to authenticate anonymous requests on your web server.  Change the settings in IIS to use this new account instead of the IUSR_... account.  Then make sure this new account has the needed permissions to the wwwroot folder on the web server.  Give this new account the same permissions that the IUSR_... account has for wwwroot.  Make sure you have that identity tag above in web.config.  Do the same thing for your dev machine's IIS settings and web.config.

Now go to the server that has the files you are trying to access by way of the UNC path.  Give the new domain account permissions on the root folder for which your web site needs access.

Now when you try to run the website on either your dev box or the regular server, the code will run under the same domain account, which has been given permissions to the file server you are trying to access.

John

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:ztot
ID: 12071432
Thanks a lot John, one last thing is, is it possible to do this on the network without domain?
Other than this, any other options to solve the same problem?

FYI, I have added following code into web.config file and gave permission for the remote machine folder for this domain user

<system.web>
<identity impersonate="true" userName="mydomain\myusername"
password="mypassword" />
0
 
LVL 10

Expert Comment

by:jnhorst
ID: 12071537
If it is a peer-to-peer network, the you would need to make sure that all machines in question had local accounts with the same username and password.

John
0
 

Author Comment

by:ztot
ID: 12072249
thanks : )
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need an intro to -- .Net SQL Authorization Manager 7 79
Trouble with References... 5 44
ASP.NET Web Form Variables being reset 2 26
SQL best practice question 3 36
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now