Can I programmatically define my IIS7 site bindings (e.g. foo.domain.com)?

for my IIS7 website, I had to go into the IIS7 service manager and define all the bindings for the site. It works great.

I was wondering if it is possible to do this programmatically in the web.config file? I know that you can provide several iis7 settings there .. was not sure if bindings can also be enabled?

eg.

  • HTTP all unassigned ip; port 80; foo.domain.com
  • HTTPS 192.168.0.2; port 443; blah.domain.com

thanks:)

+3
source share
2 answers

Host.config, , . , IIS Express , , :

<system.applicationHost>
...

    <sites>
        <site name="Development Web Site" id="1" serverAutoStart="true">
            <application path="/">
                <virtualDirectory path="/" physicalPath="%IIS_BIN%\AppServer\empty_wwwroot" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation=":8080:localhost" />
            </bindings>
        </site>
        <siteDefaults>
            <logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
            <traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
        </siteDefaults>
        <applicationDefaults applicationPool="IISExpressAppPool" />
        <virtualDirectoryDefaults allowSubDirConfig="true" />
    </sites>

</system.applicationHost>

( - ):

% windir%\system32\inetsrv\appcmd.exe config -section: system.applicationHost

web.configs system.applicationHost, .

+2

Microsoft.Web.Administration. maniuplate IIS 7 #.

Appcmd, IIS 7.0. , . , .

+1

Source: https://habr.com/ru/post/1707453/


All Articles