c# - Add Binding To IIS Without Recycling Application -


we have application allows associate multiple urls , want allow our customers add new urls themselves, have following code adds bindings:

  using (servermanager servermanager = new servermanager())   {     var site = servermanager.sites["sitename"];     var binding = site.bindings.singleordefault(x => x.host == hostname);     if (binding == null)     {       binding = site.bindings.createelement("binding");       binding["protocol"] = "http";       string ip = "*";       string port = "80";       binding["bindinginformation"] = string.format(@"{0}:{1}:{2}", ip, port, hostname);        site.bindings.add(binding);       servermanager.commitchanges();     }   } 

the issue have causes application recycle, have tested on our solution using local iis , appliation_start hit again. have manually added binding iis causes recycle. while suspect answer no solution adding binding programatically without causing application recycle?

you can try change setting disable recycling configuration changes on application pool hosting site.

in powershell:

set-webconfigurationproperty -pspath 'machine/webroot/apphost'  -filter "system.applicationhost/applicationpools/add[@name='mypool']/recycling" -name "disallowrotationonconfigchange" -value "true" 

a quick test here showed adding/removing bindings didn't unload current appdomain anymore after changing setting.

even if works, want test while make sure doesn't break else.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -