Directory listing denied on ASP.Net MVC 4 app running in IIS 6 Virtual Directory - iis-6

I am trying to get ASP.Net MVC 4 working on IIS6 and am running into the always fun Directory Listing Denied error.
Before you start posting about extensionless urls and how I need to read the Haacked blog post.. I have :) So with that out of the way here is the setup:
I have created a new Web Site and configured it to use ASP.Net 4.0. I had to do this because the existing Default Web Site is configured for ASP.Net 2.0 and this breaks extensionless urls. Under the new web site I created a Virtual Directory with Read/Write/Log Vists/Index this resource options selected and execute permissions set to Scripts.
I have verified that ASP.Net v4.0.30319 is in the Web Service Extensions list and is allowed. I have also verified that the .axd mapping is setup correctly in my virtual directories mapping configuration.
I am completely and totally stumped..
As a side bit of trivia I had this working with the web site pointing directly at my ASP.Net 4 web app but we need this to be done via a virtual directory instead. The fact I had this working should mean that the EnableExtensionlessUrl registry setting is not a problem.

I had faced the same problem and it got cleared when I added "Wildcard application mapping" (.*) to aspnet_isapi.dll with unchecked option "Verify that file exists"
Application -> Properties -> Directory -> Configuration -> Mappings ->
Insert -> Browse to
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll ->
Uncheck "Verify that file exists" -> Ok
Now the site is opening fine without any issues.

Similar issue: We installed MVC4 on an IIS6 box, set up everything as described, and got same error:
Directory Listing Denied
This Virtual Directory does not allow contents to be listed.
For us, the final fix was to add the UrlRoutingModule to the web.config:
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Which makes sense, but I don't know why we needed to explicitly add it and others didn't. (We are running in a directory under Sharepoint, maybe related...)

Related

Net 6 showing 500.19 error reading the wrong web.config

I deployed a brand new site on IIS. It is in .Net 6. I am getting a 500.19 error that it cannot read the configuration file due to insufficient permissions.
\\?\D\Sites\SiteDirectory\wwwroot\web.config
The problem is this web.config file that it is pointing to is not the one for my website. It is looking for a web.config in the wwwroot directory for some reason. As a matter of fact there is no web.config that even exists at that location.
The correct web.config file exists in
D:\Sites\SiteDirectory\wwwroot\SiteName\web.config
Why is IIS looking at wwwroot? How can I fix this behavior? My other .Net Framework 4.7 sites work fine without this web.config at the root directory.
I solved it by installing this component:
Windows Hosting Bundle
"https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-aspnetcore-6.0.6-windows-hosting-bundle-installer"

IIS is not allowing to access a javascript file

i have a web application. while running in my system integration environment, i get an issue while accessing my javascript file or an image file in my particular folder.
When i tried putting the complete URL in the browser, it gave me a following exception -
HTTP Error 404.2 Not Found
The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the webserver.
I googled this exception and found that i need to allow ASP.NET 4.0, 2.0, etc in the IIS's ISAPI & CGi Restrictions.. however, they were already in allow mode.
What next should i lookup?
OK,, i got the answer
the HTTP Handler in the applicatin's web.config file was trying to execute via a aspnet_isapi.dll located in Framework64 folder of .NET Framework.. the target machine however is a 32 bit and i dont have this Framework64 folder on it..
i changed the path of the executable to point to the 32 bit's folder and it wrked :)

Virtual Directory to navigate to http://localhost/MyWebsite instead of http://localhost:8080

I have deployed an ASP.NET MVC 4 application to a new site I have created in IIS 7.5, which I have bound to port 8080. I can reach it by navigating to http://localhost:8080, but I want to reach it via http://localhost/MyWebsite.
I have added a Virtual Directory under my website, which points to "C:\inetput\wwwroot\MyWebsite\". However, when I navigate to http://localhost/MyWebsite, I am presented with a configuration error:
"It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS."
Here is what my IIS hierarchy looks like (this is a demo since I have no internet access on the server I am working on).
I have two questions:
Why am I getting this error?
Is this the best way to go about achieving what I want? It seems messy to have the list of files and folders underneath the website and then again underneath the Virtual Directory. If there is better practice then please tell!
Virtual Directories cannot execute scripts, reason why you are getting that error. You need to make your MyWebsite folder an Application. Also, you don't necessarily have to create a separate website for your website, you can use the Default Web Site and create an application MyWebsite in there (it might be less confusing maybe?).

Default route in MVC working from VS, but not on test server

I have a very simple ASP.NET MVC 4.0 website. It's got a single controller ("HomeController") with a single action ("Index") which receives a single parameter ("string id"). I have not modified the global.asax file since this kind of route is handled by default. I have not created a view for this action since the action will simply be "sending" the user a file (a PDF). If I run the site from within Visual Studio (using a default page of "home/index/3" in project properties), the page runs fine. If, however, I publish the site to our test server (https://ourserver.com/mysite/home/index/3), I get a 404--File or Directory not found.
NOTE: We're running IIS7.5 on this server.
UPDATE: The bin dir (and the appropriate DLL, i.e., one named after the project) and the web.config file are there.
So, why is this not working?
If you're using an older version of IIS and haven't installed the MVC server extensions which give you routing, you can do a BIN deployment of the necessary infrastructure files.
Edit: If you're running IIS 7.5 you should have everything you need. You mention you don't see a web.config file or any dlls - how did you publish? You should absolutely have a web.config at the root of the publish directory and a bin folder with your dll(s).
If you right-click on your web project and do Publish, you can publish to a local directory. It'll be exactly what you should see when deployed.
Edit 2: Did you check that it's configured in IIS as a web application and not just a site?

Can't access any ASPX files on my new Win Server 2008 SP2 install, enabled folder permissions/added users but still no go

Just installed Windows Server 2008 SP2
Installed IIS, ASP.NET and other necessary roles.
For my site folder I edit the permission to include
users: Network Service and a bunch of other IIS user names
a long with that Internet guest one. Fiddled around with the
application pool (Load user profile:True , Identity Network Service etc.
Also only change I made from the default fresh install settings
was installing the .Net 4 framework.
I can view regular html files etc. But should I want to make use of ASP.NET and access an aspx page, I get the following:
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
When running a settings test I get:
The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that \$ has Read access to the physical path. Then test these settings again.
Any ideas?
THanks..
I don't have an answer I know is the solution, but here are my suggestions:
First, have you mapped the IIS default web site to the folder containing your site?
Second, check your basic apppool settings, and make sure it's set to use .Net 2.0. It'll be 2.0 even if you're using a later version, like 4.0.
Barring that, make a new folder in wwwroot and map the default web site to that. Do not mess with the permissions. Then, make a new apppool, don't fiddle with it's settings, and assign that to the default web site. Point here is that you shouldn't have to mess with any of those settings: IIS will take care of that and the permissions.
Final thought, if that doesn't help: check your isapi filter mappings to make sure it knows what to do with .aspx. That should have been set up by default as well, but it's worth a look at that point.