views:

331

answers:

1

Hi folks,

for my IIS7 website, i've had to go into the IIS7 Services Manager and define all the bindings for the site. Works fine.

I was wondering if it's possible to do this programatically in the web.config file instead? I know you can provide a few iis7 settings in there.. wasn't sure if it's possible to also include the bindings?

eg.

  1. http; all unassigned ip's; port 80; foo.domain.com
  2. https; 192.168.0.2; port 443; blah.domain.com

thanks :)

+1  A: 

Look at the Microsoft.Web.Administration namespace. you can then configure and maniuplate most of IIS 7 from C# code.

there is also a utility Appcmd that allows you to manipulate almost everything in IIS 7.0. be warned that this tool has tons of options and switches. I have only used it for the most basic of tasks such as changing physical directories on applications.

MikeJ
Hi Mike. I actually don't want to configure any of the server programatically (eg. create a new iis web site, etc). I was hoping to know if it's possible to tweak some of a single site's settings (eg. default page, list of bindings, etc).
Pure.Krome
And did you investigate the namespace he mentioned? Seems to have everything you could want.
samjudson
I don't think web.config can do this. actually I know this cant be possible because web.config can be nested in each virtual directory. the problem with this is that you might get this directive in several deep directories and how would that conflict resolve itself.
MikeJ