IIS returning 404 when virtual directory has a specific name - windows-server-2016

IIS Version: 10.0.14393.0
OS: Windows Server 2016
I'm trying to access a virtual directory via IIS which is pointed to a folder that just contains a basic html page, however it's returning 404 and I'm not sure why. It seems to have to do with the specific name of the virtual directory, let's say ABC_ABC1234. At first I thought it was a folder permission issue, but I created a second virtual directory named Test, pointed it to the same folder, and the html page loads up just fine. The only difference between the two virtual directories is the name, and they are targeting the same app pool, folder, etc.
There are other virtual directories with the same naming convention and those all work. I also tried the same virtual directory name on another server, and it works just fine. I didn't see anything out of the ordinary in the event viewer logs or in the IIS logs. I compared the entries in the applicationHost.config file and they are identical except for the name. I've tried IIS resets, server restarts, deleting and recreating the virtual directory, all to no avail.
I am pretty much out of ideas at this point. Any help or suggestions on what would cause this would be much appreciated!

Related

Asp.Net is looking for the web.config in the wrong place

I've got a strange issue - Up until now I've only worked on this application on a single machine. I've downloaded an asp.net web app onto a dev machine in a clients office.
When I try to run the application in debug mode through Visual Studio I get 500.19 error - typically this means a permission problem. I went through the motions of checking the permissions before I noticed the directory it was looking for the config file in.
The 'Config File' shown on the error is
\\?\C:\Users\{my-name}\Documents\{project-name}\web.config
however the correct location is actually
C:\Users\admin\Documents\projects\{project-name}\web.config
Does anyone know where the location of the web config is specified? I had always assumed it could only ever be in the root directory.
As it turns out the cause of this was upgrading to Visual Studio 2015.
Rather than a .suo file the new Visual Studio has a .vs folder with files specific to an instance of a project. The root directory of the development site is included in here.
I deleted the files and added .vs/* to my .gitignore file and had no more problems.
At our infrastructure it turned out that inside the web.config withing the node <system.webServer>, we had a nested node named <rewrite />. That one wasn't recognised by IIS.
By either removing that node or installing the missing feature (url-rewrite), the application started as expected.
In my case, the top level website in IIS had a physical path of:
C:\Users\MyUserName\Documents\My Web Sites
For some reason, this meant IIS refused to look anywhere else, even though my projects underneath had been converted to applications.
Fix for me:
Go to IIS
Right click on the top level website (i.e. 'Default Web Site', or the problematic website at the same level)
Select 'Manage Website > Advanced Settings'
Change the physical path to C:\inetpub\wwwroot
Save and reload website
I could then have any path for my applications and IIS could work it out as expected.
Assuming you mean Documents\projects\{project-name}\web.config instead of Documents\projects{project-name}\web.config you're seeing the effect of Application Scopes.
In IIS, multiple entirely separate web-applications can be part of the same website by being split-up into "Application Scopes" - which usually works by specifying a prefix path followed by the Scope root (prior to IIS7 an Application Scope could be a physical or virtual directory, since IIS7 they're always virtual directories, but can still represent a physical directory).
Open IIS Manager and select the (virtual )directory that Visual Studio created for your project and right-click it in the left-side Navigation pane and choose "Convert to Application", then ASP.NET will look for the web.config file (and the bin directory, amongst others) in this folder only, rather than the website root.
Note that the website root is also considered an application scope root, hence the common error message "Exception in "/" application". If you get a YSoD in another application root you'll see "Exception in "/subFolder" application" messages.

Errors after add Virtual Directory in IIS

My web service on IIS can work well w/o a virtual directory (called by http://localhost). However, I want to call it like http://localhost/virtualpath.
So I added a virtual directory in IIS, but when I explorer website, it gives me the following error:
What does this mean and how to solve it? (I'm using IIS 8.5)
It means exactly what the error says - you've tried to set a section in web config beyond application level. I'm assuming that you added the virtual directory under a pre existing website in IIS? What you want is to add a physical directory under the website with your app in and then simply right click and convert that folder to an application.

Virtual Directory in IIS 7.5

We got 2 websites (WebsiteA and WebsiteB). On WebsiteA, I chose "Add a virtual directory" and selected a folder on WebsiteB to be my physical path. The Alias is the same as the target.
As you can see, on WebsiteB, the folder "Main" is already an application.
In the forum, I saw that people with the same error forgot to convert the folder as an application, but mine is already done didn't?
I found that right clicking on my virtual directory (first image) and selecting "Convert to application" seems to work. Is it the right way to do this? By doing this, do I lose my virtual directory? I don't want to use duplicate content (if I edit something in the "Main" folder on websiteB, I don't want to edit the "Main" folder on WebsiteA manually too). I have been told to use the virtual directory as it's supposed to do the job, but none of us has used it before. Thanks
Virtual directories and applications work a little bit different in IIS > 6.0. Virtual directories used to be self contained applications in IIS 6.0, so your web.config file would be fine. But in IIS 7.0 and above, a virtual directory is just that, a pointer to a directory.
If you are looking for the same effect of a virtual directory as in IIS 6.0, you'll need to create an application underneath WebsiteA, not a virtual directory. A virtual directory in IIS 7 and above runs as a directory underneath the parent website, not as a separate application.

Setup IIS 6 to only server static files from virtual directories

We're having the same setup and receiving the same problem as:
IIS 6 with wildcard mapping and UNC virtual directory problem
Setup
Server 2003 32bit, IIS 6
ASP.NET wild card mapping
A virtual directory mapped to an UNC share serving static images for a CMS in a load balancing environment
My question if it's possible to turn off asp.net from virtual and only serve static files e.g. images in the virtual directory, to avoid the problem with too many open connections?
If it's not possible I'll guess I have to implement a solution like Version control of uploaded images to file system to server the files from a local disc.
I found a possible solution at http://blog.stevensanderson.com/2008/07/07/overriding-iis6-wildcard-maps-on-individual-directories/ that removes the wild card mapping and makes it possible to turn of execution of asp.net files.
There is not a way to remove .NET from a subdirectory as it is part of an application at this point (your root directory). However, this method works just fine for keeping .NET from processing your static content.
From your site that you linked:
Alternative
If you don’t like to use adsutil.vbs, you can achieve the same by exploiting what appears to be a bug in IIS Manager. Turn your subdirectory into an application (from its Directory tab, click “Create”). Then edit its script mappings to remove aspnet_isapi.dll. Then go back and “Remove” the application you just created. The metabase’s new ScriptMaps value will be retained, even though the option has now disappeared from the GUI.

IIS7 Creating Virtual Directory to files on another server

I am migrating some ASP.Net applications from IIS6 to IIS7 and all has gone well until now. I am trying to create several virtual directories on 1 server that will point to files on another server. In IIS6, all I had to do was make anonymous authentication use a user that had access to the files. In IIS7, I can't get it to work. I setup the virtual directory with the username and password but I get a 500.19 error "Cannot read configuration file due to insufficient permissions". I can't imagine that I really have to put a web.config in a directory that just contains images and no application files. If I click on the directory in IIS Manager, I get that error about the web.config file on anything that I click on such as the Authentication section. Also, writing to files from the virtual directory seems to work just fine so I don't think there is anyway that I have an access problem. I have given the directory access to the IIS_IUSR group.
When using a virtual directory that's pointed to a UNC share, go to advanced settings for the virtual directory, then choose a specific user account that has the appropriate rights to access the folder.
It works for my virtual directory in my asp.net app that is pointed to a UNC share on a remote server.

Resources