IIS file download - iis

I've created a new web site in IIS on my machine for testing purposes. Beneath the root I have a folder called documents where I have a bunch of pdf's that should be downloadable. However, when I hit the URL localhost:54510/documents/file.pdf I get a 404 error (Chrome, IE and Firefox).
I've added IIS_IUSRS permissions for the specified folders and the service is running since I can access my ASPNET WebApi - localhost:54510/api/whatever-service-function.
I can't grasp my head around what causes this.
PDF is specified in MIME-types as Application/pdf.
Another thing is, when I add the documents folder as a virtual directory in the Default web site then it works to download it from localhost:80/documents/file.pdf.
I have also tried to add the documents folder as a virtual directory in my web-site and set my local user as the authenticator to see if it had anything to do with permission.
I'm running on IIS 10.
Does anyone have any ideas?

Related

How do you allow IIS to access a symlink folder?

I have a two webservers, on each webserver in the C:\inetpub\logs\LogFiles I have created a symbolic link to the other servers log file folders, so essentially I can be logged in to one of the webservers and see the logs on both servers in one place. This works perfectly.
I am building a webpage to make the log files available via a webpage, the code simply goes to the C:\inetpub\logs\LogFiles directory and lists the files in each sub folder, i.e. W3SVC1 (the local folder) and webserver2-w3svc1 (the remote log folder).
For the local folders it works fine, but I am getting the "access denied" error when trying to call Directory.GetFiles on the symlinkd folder. I suspect this is some sort of permissions error, but I tried giving the symlinkd folder full permissions to "everyone" but I still get the same error.
Is this something to do with the fact that when I created the symlinkd I had to enter the username and password of the webserver2, and these credentials cannot be accessed/used by IIS when trying to get access to the folder?
Is there anything I can do allow IIS to access the contents of this symlinkd folder?
I don't think you need to use a symlink, you can create a virtual directory mapping to that directory in IIS, just map it to the target path. In IIS, right click on the website and select Add Virtual Directory.
For more information, please refer to this official document.
After much experimentation, the only way to do this is as follows:
Create a new user on the computer.
Run the AppPool in IIS under this new users' identity as opposed to the default IUSR account.
Give the folder you are sharing permissions to this user AND 'share' this folder with the new user.

How can I set permission to all new sub directories on windows server created by java?

I have a website hosted on IIS and I created a virtual directory ("pictures") which physical path is "C:/mydir/mysubdir". Inside "mysubdir" there are many sub-directories (for example: "123", "456" and so on ) containing images that are shown on the website with a regular html tag.
Until now everything is working fine and images are shown, the problem occurs when the back-end application hosted on Tomcat installed on windows server and connected to IIS goes to create new sub-directory under the physical path, the images inside the new folder are not shown due to an Unauthorized access 401, the work around I'm doing is set share permission all the times the user is creating new sub-directories via webapp but you can understand that is not possible do this all the time, this must work alone.
I already set all read/write permission to the Administrator account, even shared the parent folder and set the inheritance but is not working.
The owner of the folder is different if create from tomcat (LOCAL USER instead of Administrator) and I don't know if this could be a problem.
Please help me to find a solution.
Thanks in advance.
You could try the below steps to resolve the issue:
1)select your folder under which the new subfolder is creating by another user.
2)Right-click on the target folder/file and select Properties.
3)Security → Advanced.
4)click on the add and add user application pool identity(IIS AppPool\ (eg: IIS AppPool\smartcrypt)), iis_iusrs, and iusr.
5)by clicking on show advance permission set full control. and in applies to make sure it set to this folder, subfolders, and files.
6)click on and apply the setting.
7)in application pool identity set one of these network services, local system or application pool identity.

Modify the default website in IIS 6.0

I have IIS installed on a server.
It is currently on the intranet as http://mySite which has a few basic html pages that load when you go to that URL
I've made a virtual directory called MyWebApp, which sits at http://mySite/MyWebApp
How do I go about making MyWebApp the default site when you type mySite into the browser?
I don't want it to come up as mySite/MyWebApp when you visit the page either.. I just want it to always say mySite.
Wouldn't it just be simpler to build your app in your root directory? However, you can change the root directory of your IIS6 website by:
To change the home directory of a Web site using IIS Manager
In IIS Manager, expand the local computer, expand the Web Sites directory, right-click the Web site you wish to change, and click Stop.
Use Windows Explorer, to rename the LocalDrive:\Inetpub\Wwwroot directory to the name of your choice. Alternatively, you can copy the entire \Wwwroot directory tree to a new location.

Legacy ASP site issue

I'm dealing with an issue where there was a site setup, and the default.htm used an iframe which pointed to an ASP directory. It seems like the ASP directory isn't readable and not processed - is there anything special that needs to be done to the ASP directory like permissions-wise?
wwwroot/sitename
<iframe src="ASP/file.asp"></iframe>
wwwroot/sitename/ASP/file.asp exists, and several other asp files but they aren't getting referenced by the iframe.
Update: I'm getting a 404..
The page cannot be found
I think I have to create a virtual directory and name it ASP. I never use IIS though - does anyone know how this works? And would I need to restart IIS after creating the virtual directory?
Update #2: More info..
Execute permissions: Scripts Only
Application name: asp
For Authentication Methods, "Integrated Windows authentication" is checked
Local Path: Read
Update #3: I can access asp/file.htm file fine. Can anyone provide code for a simple test I could do to see if its working properly ( I have no ASP/VBScript experience )..
one of the top of the pages contains <%# LANGUAGE="VBSCRIPT"%>
Is this IIS6 by any chance? In IIS, under Web Sites there is a folder called Web Service Extensions. Make sure Active Server Pages are set to Allow and not Prohibited!
When you create a virtual directory for an ASP site in IIS, you have to make sure it is allowed to execute scripts. What version of IIS are you using? In 5.0 and 6.0, there should be a checkbox Run Scripts (such as ASP). Make sure that's checked.
Try putting a test.html file in the root directory of the site and then try to open it through wwwroot/sitename/asp/test.html - .html files won't be processed by asp.dll and so should display if the site is setup correctly even if there is some kind of asp.dll problem.
If you can't see a html file then I guess you will need to configure the website in IIS (not sure if a virtual directory is necessary from the information given) - check the 'home' tab to see if the path to the application is correct first.
If you can see the html file then I'd guess that asp is not properly installed (but that is a guess).

IIS7 - Uploading files with ASP problems

We've just moved our website to win2008 and IIS7 from win2000 with IS5 and I have some problems.
I have a folder that in it is an ASP page that upload a file to an upper folder, in the old IIS, I gave to the folder with the ASP page the permissions of the administrator and it's work fine, the files could be uploaded to an upper folders. BUT in the IIS7 I can't do it, I give to the folder with the asp code all the writing permission and it's not working. It's only work if I give a writing permissions to the upper targert folders. I don't wont to give to the target folders a full permission because those are the main web site folders.
So how can I do it? How can I give a folder a permission to write also to an upper folder that doesn's have this permmision?
Thanks
One possible reason is that you are attempting to access the parent with a MapPath and this is failing because Parent Paths haven't been enabled.
Since IIS6 the ability for code to access parent folders is by default blocked. To do this it is necessary to enable parent paths. In IIS7 parent paths can be enabled at Server, Site, Application or Folder level. In IIS manager click on the site, application or folder you want to enable this for, double click the ASP icon, in the Behavour section set 'Enable Parent Paths' to True.

Resources