Solved

Upload File to Mapped Drive

Posted on 2004-09-14
6
486 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 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