IIS

It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level

Scott Michell wrote an excellent article about the above error explaining exactly why are you getting this error. Basically you are opening the parent folder of a project in Visual Studio and you get this error. Since web.config in this case is in sub folder, you get this error.

A little Explanation

There can be more than one web.conf files in your application. They can be all in root or in sub folders as in nested form. The root web.conf can contain almost all elements but that that are nested in sub folders may not contain certain elements. This error is about this scenario.

Resolution

Lets say you have project in this folder

d:\project\myfirstapp\main\

If you open myfirstapp in Visual Studio you will get the above error. To resolve reopen the project and select main as your project.

set up new website in iis7

Setting up new site in IIS can be tricky. Actually the process is easy most of the time it may not work for you mainly because of Application pool setting or for other unknown reason. I had similar issue setting up site in IIS7 today so I will write all the steps, What you should be doing and what you should not be doing.

This tutorial is for IIS7 on Windows7 System.

Steps to Setup Site in IIS7

  • Start IIS by typing IIS in Start-> Search Box. If it is not installed you have to install by going to Add/Remove Windows Components
  • Inside IIS, got to Sites, right click , Add new site. Name It local.yahoo.com.IIS7 Add new site
  • Select “Local.Yahoo.Com” then select Basic Binding. The following dialog will pop up.Screenshot 2014-09-22 19.27.41
  • Select the directory from where you want to server the site. But importantly click on the Connect as button select the user who has full permission to the directory. This is important as authentication will fail later if you do not complete this step. If you are logged in with username which does not have password. Go to System Users and create a new user, name it something like “FOR IIS” and set user name and password. After you enter those credentials here, click on “Test Settings” button and make sure both the permission have green icons.
  • Next click “Binding” from the right side, just above “Basic Binding”. The following dialog will pop up.Screenshot 2014-09-22 19.31.05
  • In the above dialog, highlight the entry, edit will become active. Then click edit. In the host name, click “local.Yahoo.com”. Leave port 80 as it is as you want to direct all traffic through this port. IP Address can be to local IP or leave it as a steric. Both options are available from drop down.
  • Edit Windows host file which is located in c:\Windows\System32\drivers\etc\hosts. You will not Administrator permission. Open Notepad first by right clicking on it and select “run as administrator”. Then File open, give location.
  • Enter the following entry in a new line “127.0.0.1 Local.yahoo.com”
  • Go to the binding property again, click edit on local.yahoo.com and select the browse button. It should display contents in your site if there is any index.html or default.aspx page.

Setting up Multiple Sites

You can setup multiple sites in IIS by proving hostname in the “Binding Dialog” and corresponding enter that host name in the Windows host file as well.

When you provide hostname in binding dialog (as we did Local.Yahoo.com), IIS recognizes that hostname and will server the appropriate site when request from a recognized host is received.

Issue with IIS Sites

There is a fair chances the site will not work in first chance. In my case, I had to play with Application pool. Changed it from V2 to V4 and Playing changing setting from Integrated to Classic. Somehow that resolved it for me, not sure why. The other sites that I created worked in Integrated mode V2 which the first site did not work. So I am not really sure why it works one time and why it doesn’t the other. Probably it is some type of bug in II7. The solution is trying changing Application pool setting, recycle it and restart the site, it *might* work.

Note that you do not need to Add Application to your website. It should work without adding any application.

If this tutorial was useful, please comment below so I can continue my other writing.

In case of Proxy Server

If you use proxy to access internet or use resources over network, you will have to add exception or use not proxy for your local site.

In FireFox, go to top menu, select Tools > Options > Advanced> Network tab > Connection Setting. Type your local domains in “No Proxy for” area. This step is required if Proxy is configured on your machine.

Summary of Errors I was getting

Explanation: The IP address for the website you requested could not be found.

The above error resolved by itself on first machine when I was playing with Application Pool Settings.


The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.


HTTP Error 500.21 – Internal Server Error
Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list