0

I have configured a website in IIS with a host header, so that I can call the url customhostheader/ and the website will be shown.

When I try to publish my web project, I get the error that some sections in web.config are registered as allowDefinition=MachineToApplication. But I cannot convert the website in to an application in IIS. I can only convert virtual directories into IIS applications, but I don't want the much longer url http://customhostheader/virtualdirectoryname, I prefer to have just http://customhostheader.

Any ideas what I could do?

Thanks.

froggy
  • 51
  • 2
  • 11
  • You don't need to add a new website to host your code. Rather you need to add an application – Taleeb Aug 23 '15 at 09:21

1 Answers1

0

Add an application with the name customhostheader which is pointing to your published code (parent of bin folder)

To do this

  1. Right click on "Default Web Site" in IIS and select "Add Application"
  2. Give alias as customhostheader and provide the path to your application.

enter image description here


Edit based on the comment

Each website by default contains an application. So we just needs to make sure the path of the website is correct.

The following two points should be enough to set up the correct path

  1. The path should be parent of bin folder
  2. The web.config should be present on the path

The default document can be set through the IIS or web.config

Taleeb
  • 1,888
  • 18
  • 25
  • If I just add it as an application to the default site, I cannot access it by customhostheader.domain.com. – froggy Aug 23 '15 at 15:01
  • ok... By default - each website contains one application ('/') - so if your website is pointing to the correct path it should work. You need to make sure two things :- 1. The path should be parent of the bin folder. 2. The web.config should be present at the path. – Taleeb Aug 23 '15 at 15:27
  • 1
    I have found out that the problem was the bin and obj folder. The publishing within visual studio is highly unstable, sometimes it deployed to the incorrect destination chosen before or threw the exception the destination is not an application in IIS. Even if the configuration was kept the same the error not always popped up. Since I delete the bin and obj folder before every publish, it works. Thanks for your help. – froggy Aug 25 '15 at 04:43