1

I want to know if the following is possible to accomplish & whether it is or isn't, get as much feedback so I can find a way to start.

I want to create a site in IIS. This site I would want to have 2 bindings:

test1.company.com
test2.company.com

However, when users access the website, I'd want test1.company.com to use Forms Authentication & test2.company.com to use Windows Authentication.

In a nutshell, that's what I'm trying to accomplish. The things I've tried so far were:

  1. creating 2 separate websites (test1.company.com & test2.company.com) & in Basic Settings, have both websites point to the same Physical path. However, I believe this won't work because when I change the authentication on one website, it will also apply it to the other & vice versa since I guess they're both using the same physical path.

  2. creating 2 separate websites again, but instead, in Basic Settings, have both websites have their own folder/physical path. However, the folders of each website are exactly the same. This works, however the site will be edited (files will be added/changed to the root folder) so whatever is added/changed on website will need to be exactly done the same on the other, if that makes sense. This poses an inconvenience & would not like to go this route.

So in the end, just wanted to get some feedback on if what I want could be accomplished. If any more details are needed, I can explain. Any help will greatly be appreciated.

authentication iis binding

1 Answer 1

2

You can go with option 1, two separate sites pointing to the same physical path. When you set forms authentication for the first site you get a web.config with:

<configuration>
   <system.web>
      <authentication mode="Forms" />
   </system.web>
</configuration>

If you choose Windows authentication on the second site you get:

 <configuration>
     <system.webServer>
         <security>
             <authentication>
                 <anonymousAuthentication enabled="false" />
                 <windowsAuthentication enabled="true" />
             </authentication>
         </security>
     </system.webServer>
 </configuration>

Now you have a conflict in your single web.config file. To resolve this, move both nodes out of the web.config file into the global IIS config file.

Open:

C:\Windows\System32\inetsrv\Config\applicationHost.config

in a text editor as elevated administrator and at the bottom add something like this:

<location path="test1.company.com">
   <system.web>
       <authentication mode="Forms" />
    </system.web>
</location>

<location path="test2.company.com">
      <system.webServer>
          <security>
              <authentication>
                  <anonymousAuthentication enabled="false" />
                  <windowsAuthentication enabled="true" />
              </authentication>
          </security>
      </system.webServer>
</location>    

The name in the location nodes is the same you see for the site in IIS Manager. You may already have other location nodes in applicationHost.config, otherwise put them directly under the configuration node.

Any other configuration that is shared between the two sites can stay in the web.config.

The path in the location node is not limited to the site name, it can also have a directory or file to apply settings to a particular part of the site.

2
  • Appreciate the help Peter. Will try this today. However, because all of this is fairly new to me, can you perhaps elaborate a little bit more about moving both nodes out of the web.config file? Do you mean making sure the web.config file has no traces of any types of authentication since I'll be setting them in the global IIS config file?
    – RayMontez
    Oct 8, 2018 at 15:08
  • @RayMontez - exactly, because you are sharing the web.config, you can't have anything in it that you need for one site but not the other. All those things have to go into the global config file. Oct 8, 2018 at 16:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .