Solved

Upload File to Mapped Drive

Posted on 2004-09-14
6
484 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:ztot
Comment Utility
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
Comment Utility
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
Comment Utility
thanks : )
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

8 Experts available now in Live!

Get 1:1 Help Now