I have 1 service app(asp.net) that will upload txt file.
I would like to upload the file to network share drive.
example of network mapped drive: Z:\HR\hr\t\clock.
If i run the web page throught visual web developer, it can successfully save the file.
but if i run the web page directly via IE, it cannot save.
I already set the network folder for everyone is full control right.
it throw an exception System.IO.DirectoryNotFoundException: Could not find a part of the path 'Z:\HR\t\clock102528122011113418.txt'.
Thanks
That will be because of Security Contexts I would think.
Running it from VWD runs under your security context, running "directly from IE" will run under a different context (Traditionally, IUSR_MachineName)
One scenario you have an account that has permissions, the other you do not.
I would recommend creating a service account to do the work and give that the least permissions possible and go from there.
Related
Our department is in the process of moving to a new domain. We were all given new network logins etc. Our computers are part of the new domain, everything seems to be ok. I've copied all my files over, but when I run visual studio, I get the classic error...
Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. Access is denied.
Now, I know this is a permissions issue, and I assume it's happening because I'm running visual studio as a different user, and the file permissions need to be redone. I've tried adding and granting full access to c:/users/myNewNetworkID/appData/temp for IIS_Iusers, Network services... I remember when I started this job and the PC was new that I had to change a bunch... does anyone know exactly what folders need to have new permissions assigned? I also tried granting those users full access to the temp asp.net folder in Microsoft.net/framework64/... but I'm still getting this infuriatingly vague error. any help would be greatly appreciated...
I've had this problem before and have found that granting full control to the group called "Everyone" for the folder C:\WINDOWS\Microsoft.NET\Framework[.NET FRAMEWORK VERSION]\Temporary ASP.NET Files does the job although your error could be caused by something else. The folder above is where temporary files are stored when apps are compiled for the first time (this will probably include a shadow copy of the Ajax Control Toolkit listed in the error above) are temporarily stored
Find this folder in Windows Explorer, right click on it, select properties, go to the security tab, grant access to the 'Everyone' group)
There's a lot of questions floating around on here and the web, however I couldn't resolve my issue with them.
My app pool user is set to NETWORK SERVICE, and I've verified on the folder that it is has full access (Every permission is checked). However, when I initiate a GET request to download a file it says Access to the path is denied.
I'm using .NET 4 and webforms on IIS6.
So the problem ended up being that the file itself didn't have the NETWORK SERVICE user assigned to it as I dragged the files into that directory without having the web site create them.
I was under the impression that setting the user on a directory would affect files within.
I have a file uploading and viewing page in ASP.Net 1.1 using VB. Now the page will be visible in intranet as well internet. Here in my case the intranet and internet servers are different. How can i save the uploaded file in the intranet server and view from there subsequently when the activity is done using the internet server?
I'd suggest that you have both instances of the application (intranet and internet) save their uploaded files to a common location. I'm going to assume, given that you're targeting .net 1.1 that you're probably looking for a solution/directions for IIS 6.0 or below, rather than the 7.x that comes with Vista/Server 2008.
You need to firstly decide where you're going to store the uploaded files, it could be on the Intranet server, the Internet server or a 3rd "filestore" server. Having done that, you can map that location to a commonly named Virtual Directory on each of your two web servers as follows:
Start "Internet Information Services (IIS) Manager" (Start > Control Panel > Administrative Tools)
Expand the "Web Sites" node and find the virtual directory for your application
Right click on the virtual directory and choose "New" > "Virtual Directory..."
In the wizard that appears, give the folder alias as something like SharedUploadFiles
Specify the path in the next step as something like \\192.168.100.1\SharedUploadFilesStore (i.e. wherever you've chosen to store the files
The next step will require security credentials. Set these as a username and password that has read/write access (as appropriate) to the share you've specified in step 5.
In the "Virtual Directory Access Permissions" step set the permissions as appropriate, click Next and then Finish.
Your application will now be able to access files in that share as if they were part of your web servers file system. So, if you had a file located at \\192.168.100.1\SharedUploadFilesStore\sample.txt, you would then be able to access it through both:
http://internetdomain.name/MyWebAppName/SharedUploadFiles/sample.txt
and
http://intranet.mycompany.local/MyWebAppName/SharedUploadFiles/sample.txt
My knowledge of how to solve any issues you encounter whilst configuring this isn't that deep, and you'd probably get a better answer at http://www.serverfault.com/ as whilst your question is a programming one, the answer I've given isn't a programmatic solution (not that it always has to be! =)
No matter what I do such as give Network Service and the ASP.NET account full rights to the folder that contains the image, I am still getting this error for a System.IO.File.Move. Anyone know what other accounts I may be missing here? Network Service is the account running the app pool under which this site runs on and I gave Network Service full rights to the entire folder.
I've tried everything. I gave Network Service and the machinename\aspnet full permissions to the folder that contains this .jpg. I'm testing this code and this move on localhost...my developer machine.
Have you tried using SysInternals FileMon now part of Process Monitor. You can use it to watch for the file access events or the access denied event.
It might be because you write into some other folder that is not under the ASP.NET application (eg %TEMP% folder or something). In this case the account used is IUSR_MACHINENAME which represents anonymous user.
You either need to impersonate, use another folder or give write privileges to IUSR_XXX (which I don't think is a good idea) to deal with that.
On the machine hosting the shared drive, make sure to set things up under both these tabs:
Sharing -> Permissions
Security
Most of us deal with the Security tab for getting IIS stuff working, but it was the former that was giving me the same issue with the .MoveTo() method. (It could read, just not move).
To further complicate matters, I also had the directory shared as multiple names - make sure to check the permissions for each shared name.
When setting up a virtual directory under IIS using a UNC path to a remote share, what user identity should I be expecting to see the read request to the share come under?
I've setup the above scenario and configured the user under 'Connect As' as a known user who has permissions on the remote share, which I checked with Windows Explorer.
However, when trying to access a file from within a web browser on the share using http://localhost/myfiles/atestfile.txt, I am getting an HTTP Error 401.5 - Unauthorized: Authorization failed by an ISAPI/CGI application error returned. 'myfiles' is mapped to the remote share and atestfile.txt resides in the shared folder.
If I use sysinternals filemon application to see what process and user the read request to the share is being carried out under, then I get the details that the request is through the w3wp.exe process and the user is shown as "NT AUTHORITY\NETWORK".
I was expecting the user to be shown as the user I confugured under the 'Connect As' option.
Any guidance appreciated.
If i recall correctly (used iis about 4 years ago) it was IUSR_. I'm not sure that it's still so, but give it a try.
Edit: try to give a look at this post, maybe you will find some clues ;)
Did you try it also with other file extensions than "txt", maybe "test.html"? What DLL is used for txt in the ISAPI extensions configuration (web -> Home Directory -> Configuration...)?
The section "To configure security and authentication for a virtual directory" in the MSDN article "How to: Create and Configure Virtual Directories in IIS 5.0 and 6.0" should contain the information you'll need for finding the right configuration.
I guess the account used in the security settings should be able to access the network share. This could be accomplished inserting the account in the right group or changing that account.