Sometimes, on my Windows 7 laptop, my ASP.NET MVC applications would fail with an error like:
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.
Detailed Error Information
Module DirectoryListingModule
Notification ExecuteRequestHandler
Handler StaticFile Error
At the same time other MVC applications worked fine. So, I knew I had everything installed correctly. I tried the ideas in ASP.NET MVC on IIS 7.5 but none worked for me.
My guess was that MVC or ASP.NET was not configured correctly, so IIS did not interpret the URL correctly and map it as an MVC application that should use routing. The correct HttpModule was not being found, so IIS was treating the request as for a static page and redirecting to the folder, but since directory browse was not enabled, I was getting the error.
I finally stumbled around my file system and noticed two directories with config files:
C:\inetpub\temp\appPools\DefaultAppPool\DefaultAppPool.config
C:\inetpub\temp\appPools\ASP.NET V4.0 Integrated\ASP.NET V4.0 Integrated.config
These config files contained a bunch of incorrect application definitions. Some of these were for applications that did not show up in IIS Manager. Here is an example of two (one is incorrect, one is correct):
<system.applicationHost>
<sites>
<site name="Default Web Site" id="1" serverAutoStart="true">
<application path="/appsuite/billing/customer/log-in" applicationPool="ASP.NET V4.0 Integrated">
virtualDirectory path="/" physicalPath="C:\dev\appsuite\trunk\appsuite.Services\Billing\src\Billing" />
</application>
<application path="/appsuite/billing" applicationPool="ASP.NET V4.0 Integrated">
<virtualDirectory path="/" physicalPath="C:\dev\appsuite\trunk\appsuite.Services\Billing\src\Billing" />
</application>
My problem was when I attempted to request a URL that matched one of these apps with a bad path, like http://localhost/appsuite/billing/customer/log-in, I would get the 403 error.
I deleted everything in C:\inetpub\temp (I figured, hey it's a temp folder) and after hitting my url, the config files came back. I then manually deleted from the config file the applciation that matched my url and the app started working.
Where do the settings for these config files come from, where is the data coming from after I deleted them?
How can I clean up the old junk that is in them that isn't used any more?
I suspect I created this mess in Visual Studio. Sometimes when setting the Web properties of a project, I would accidentally set the Project URL to my launch URL, when I really meant to set the Start URL to this value. My guess is this set up a new web app with the url that matched my start page.
Related
I have an MVC5 app in VS2013. I need to add some handlers to the root Web.config. This works fine with no virtual directory, but when I specify a virtual directory, IIS Express fails.
This is easy to reproduce in VS2013:
Create a new ASP.NET Web Application. Select MVC and no authentication
edit the top level Web.config. Add the following lines to the bottom, right before the closing configuration tag:
<system.webServer>
<handlers>
<add verb="GET" path="*.png" name="Static for png"
type="System.Web.StaticFileHandler" />
</handlers>
</system.webServer>
</configuration>
The application will run fine. Now, go to the Project properties, "Web" tab, and add an application name like "WebTest" to the project Url. Click the "Create Virtual Directory" button and acknowledge so that VS will let you save.
build and run
You get an error 500.19 - Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Static for png' .
IIS Express is running the app at two URLs, one with the name and one without. The URL without the name (http://localhost:52065/) comes first and works fine; the one with the name comes second and has the error. By the way, VS2010 just runs the app with the name and this works fine.
Poking in the MyDocuments\IISExpress\config\applicationhost.config file, I see the two entries for the app, both pointing to the same physical directory:
<site name="WebTest" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\_Dev\WebTest\WebTest" />
</application>
<application path="/WebTest" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\_Dev\WebTest\WebTest" />
</application>
I don't understand why there need to be two entries. I tried:
removing the first application entry. This causes an unrecognized
configuration path error.
duplicating the entire solution, and pointing the first entry at it. This gets the same duplicate error.
Some Context: I need the static handlers because this app has to be structured as a collection of independent dlls. I embed the content into the dlls
at build time and then use a VirtualPathProvider to intercept each path request and return a stream from the dll. I've found that this only works if the static file handler is in the root Web.config; otherwise my VPP doesn't get the request.
The dlls are in a Plugin directory under the project root directory. Putting a config file there didn't help either.
What am I missing? Is there a way to get IIS Express to run the app only with a name and avoid the duplicate key error?
You must always keep in mind, that ASP.NET applications under the same web site inherit parent's configuration. That means, the WebTest application will have one "Static for png" from itself, and another "Static for png" from its parent (the site root application).
Thus, as #hobwell pointed out, you must add a tag to avoid duplication.
In prod my site (mvc5) is hosted on https://company.no/myApp/ where myApp is an Application on IIS.
In dev my site is hosted on IIS Express on http://localhost:54307/
As this causes some truble with server relative paths I would like to also do my debugging on http://localhost:54307/myApp.
This is what I've tried:
Setting project url in property pages to http://localhost:54307/myApp and clicking Create Virtual directory
Tried the override application root with or without the myApp url.
Tried modify the applicationhost.config. Currently my setting looks like this:
<site name="MyApp.Web-Site" id="38">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
</application>
<application path="/MyApp" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:54307:localhost" />
<binding protocol="https" bindingInformation="*:44307:localhost" />
</bindings>
</site>
When I try to open page from the myApp folder I get the follownig error:
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x800700b7
Config Error Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'WSFederationAuthenticationModule'
Config File \\?\C:\Projects\OP\MyApp\Main\src\MyApp.Web\web.config
Requested URL http://localhost:54307/MyApp
Physical Path C:\Projects\OP\MyApp\Main\src\MyApp.Web
That indicates web.config loaded twice. Any idea what I'm doing wrong?
Thanks for any help
Larsi
I hear you with IIS Express causing problems with server relative paths. You can set this up with a couple steps that don't include manually editing your applicationhost.config. I try to avoid editing the applicationhost.config manually, it seems to cause more problems than it solves. I would remove the website from your local IIS to clear out any of that stuff and then do the steps below:
right-click on your web project and select properties.
Click on the "Web" menu
change the dropdown to Local IIS and enter the URL you would like the app to resolve to then click create virtual directory, save the file and build.
You can still debug without the port number, the debugger will just attach to this new website in your local IIS instance as long as you have a debugger option checked on the web tab.
open your local IIS and make any other configurations that are required for your app to run (Authentication, Application Pools, etc.).
open your browser and navigate to http://localhost/YourAppName
since this is a website as far as your local iis is concerned, you can hit it anytime in a browser without needed Visual Studio running.
I have taken over the maintenance of a production website at a new job that is written in ASP.NET 4 Webforms and that runs on IIS 6 on Windows Server 2003. I am not familiar with Webforms nor managing IIS...so I am kind of working things out as I go here.
I have done several deployments to our production server which have worked fine, but am now setting up a test environment that is identical, just a different IP address/domain, so we can properly test changes first.
I have a problem where on this test site any URL that does NOT end with a reference to a file (always .aspx on this site) will return a 403 error on this server. For example http://users.test.oursite.com/admin will always return a 403 error when logged into the site. It should be redirecting to http://users.test.oursite.com/admin/organisation.aspx. Having an MVC background I am not even sure how this happens...but it does in production.
Browsing links within the site is fine as they always reference an .aspx file. Manually typing URLS that reference an .aspx file is fine, just not when the URL does not contain a file. This is not a problem on the production server.
As I said, I am not familiar with WebForms or managing IIS itself...so I have kind of run out of places to look.
Is there anything that comes to mind that I should be looking at that could be causing this problem?
In WebForms typically there is no routing involved.
You need to either provide a full path on the URL ending with .aspx OR
setup default documents for your website. (Index.aspx, Default.aspx etc.)
http://www.iis.net/configreference/system.webserver/defaultdocument
OR
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="home.html" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Default documents can be setup in IIS Properties or via web.config.
Otherwise you need to provide the full path.
And because you haven't setup the DirectoryBrowsing (in IIS), you get a 403 Error when you try to access the Directory.
Enable the Directory Browsing option in IIS (not recommended) if you want this error to go away.
I want to use the auto start facility to ensure my application cache is always populated and ready to go, as described in ScottGu's blog. I'm having some problems with configuring it.
The project has a working title of IceCream, I am using Windows 7, IIS 7.5, ASP.NET 4.5.
In IIS, I have created a new application pool, IceCreamPool, and I have amended applicationHost.config as detailed in the blog posting.
Firstly: I added the startMode to AlwaysRunning on the application pool:
<applicationPools>
...
<add name="IceCreamPool" autoStart="true" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
...
</applicationPools>
Next, I added the serviceAutoStartEnabled and the serviceAutoStartProvider to the application:
<application path="/IceCreamCMS" applicationPool="IceCreamPool">
<virtualDirectory path="/" physicalPath="C:\Projects\IceCreamCMS\IceCreamCMS" serviceAutoStartEnabled="true" serviceAutoStartProvider="PreWarmMyCache" />
</application>
Then I added the service auto start provider, just after the <sites> element:
<sites>
...
</sites>
<serviceAutoStartProviders>
<add name="PreWarmMyCache" type="IceCreamCMS.PreWarmCache, IceCreamCMS" />
</serviceAutoStartProviders>
Over in the application, IceCreamCMS, I created the class called PreWarmCache as follows:
using System.Net.Mail;
public class PreWarmCache : System.Web.Hosting.IProcessHostPreloadClient
{
public void Preload(string[] parameters)
{
// Perform initialisation and cache loading logic right here
SmtpClient s = new SmtpClient("webmail.example.com");
s.Send("website#example.com", "me#example.com", "Pre-warming the cache", "Hello there...");
}
}
I then rebuilt the application, but no emails were forthcoming.
I executed an iisreset to see if I got an email then, but the iisreset gave me an error:
The worker process for application pool 'IceCreamPool' encountered an
error 'Configuration file is not well-formed XML ' trying to read
configuration data from file
'\?\C:\inetpub\temp\apppools\IceCreamPool\IceCreamPool.config', line
number '3'. The data field contains the error code.
There applicationHost.config is definitely well formed, I haven't made a basic typo, I ran it through an XML validator to confirm. So, the next obvious place to look would be the config file it states in the error, but it doesn't exist, so I'm guessing since it was in \temp\ it doesn't stick around long enough for me to look at.
I know there's a problem with either my C# bit, or how I've configured the serviceAutoStartProviders, since if I remove the serviceAutoStartProviders section and remove the setting from the <application> element, leaving just the startMode="AlwaysRunning" on the application pool, then I get no problems.
So - any ideas? How do you map your class against the serviceAutoStartProvider? I've tried having my class in no namespace, a namespace which is the name of the application (IceCreamCMS) and a longer namespace; all to no avail.
If anyone's actually got this working, could you share your config and C# code? The original blog post frustratingly doesn't give a final working example!
OK - I just tried out the exact same thing but deployed to a server running Windows Server 2008 and IIS7, and it worked perfectly.
So it must be something about IIS running on Windows 7 - but I'm happy that it's working on a server, so - no worries.
IIS7 Windows 7 64bit
No matter what I do I can't seem to add an application to a web site.
When I 'Test settings' I get "Invalid application path".
Any one have a guess as to what I could be doing wrong?
When I got this error it appeared to be due to a security setting. When I changed the "Connect As" property to an administrator then I no longer got the message.
Obviously this isn't a good solution for a production environment - one should probably grant the least privileges necessary for the user IIS is going to be using by default. I'll update this answer if I learn more.
The error message might be a bug. I ignored it and everything worked for me.
See Here: http://forums.iis.net/t/1177952.aspx
and here http://forums.iis.net/p/1182820/2000936.aspx
I eventually tracked this down to the Anonymous Authentication Credentials. I don't know what had changed, because this application used to work, but anyway, this is what I did:
Click on the Application -> Authentication. Make sure Anonymous Authentication is enabled (it was, in my case), but also click on Edit... and change the anonymous user identity to "Application pool identity" not "Specific user". Making this change worked for me.
Regards.
Go to your HTTP bindings in IIS (select your website, then on the right click on Bindings...).
Delete your SSL and your HTTP binding. Re-Add them.
This usually fixes this for me.
Try : Internet Information Services (IIS) Manager -> Default Web Site -> Click Error Pages properties and select Detail errors
Problem was installing iis manager after .net framework aspnet_regiis had run. Run run aspnet_regiis from x64 .net framework directory
aspnet_regiis -iru // From x64 .net framework directory
IIS Manager can't configure .NET Compilation on .NET 4 Applications
I was also getting this error, I found that it was because I had deleted the Default Application Pool "DefaultAppPool". Re-creating it fixed the problem. Drove me crazy for a few days.
This error will appear if either the web application is mapped to a non-existent app-pool; or if that application pool is stopped.
I also had this error.
My IIS Website has a Default Website with three (3) application directories below it.
I had each of my 3 application directories configured correctly to use .NET Framework v2.0 in the Application Pools.
However, the Default Website never was configured. I didn't think it was necessary since all of my apps were contained within it.
My IIS Server's default configuration is .NET Framework v4.0, so I changed that to .NET v2.0:
After I did that, I no longer received the same error message.
Now, I see this:
I hope this information helps others.
I was also getting this error. The problem for me turned out to be that I had two separate websites on the machine, and I had not designated which address went to which website. To resolve this, go to IIS Manager -> Select Web Site -> Bindings -> Add... -> Enter the host name that you want to resolve for this website. Repeat for any other websites on the machine.
HTH. Rick
I had a similar issue today. It was caused by skype! A recent update to skype had re-enabled port 80 and 443 as alternatives to incoming connections.
H/T : http://www.codeproject.com/Questions/549157/unableplustoplusstartplusdebuggingplusonplustheplu
To disable, go to skype > options > Advanced > Connections and uncheck "Use port 80 and 443 as alternatives to incoming connections"
I still haven’t find a solution, but find a workaround.
You can manually change IIS configuration, in system32\intsrv\config\applicationHost.config. Just manually create (copy-paste) section in <sites> and <location>.
This worked for me. (btw its not recommended.)
For my test app , I created a new application pool and changed its Identity to "NetworkService" .
More about App Pool Identities here
http://www.iis.net/learn/manage/configuring-security/application-pool-identities
and
http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis
You have to make sure that "NetworkService" has rights on your application's physical path.
even it was getting the above error. i found out that IIS was not registered on the server.
registering the iis fixed the issue.
Thanks,
In my case I had virtual dir. When I accessed main WCF Service in main dir it was working fine but accessing WCF service in virtual dir was throwing an error.
I had following code in web.config for both main and virtual dir.
<security>
<requestFiltering>
<denyQueryStringSequences>
<add sequence=".." />
</denyQueryStringSequences>
</requestFiltering>
</security>
by removing from web.config in virtual dir it fixed it.
I was able to correct the flaw by changing the file below:
C:\Windows\System32\inetsrv\config\applicationHost.config
In:
<application path="/" applicationPool="ASP.NET v4.0">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\Bonobo.Git.Server" />
</application>
<application path="/Bonobo.Git.Server" applicationPool="ASP.NET v4.0">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\Bonobo.Git.Server" />
</application>
For:
<application path="/">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\" />
</application>
<application path="/Bonobo.Git.Server" applicationPool="ASP.NET v4.0">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\Bonobo.Git.Server" />
</application>