IIS7 Add New ASP.NET Web Form Host Web Site / Header

How can I create a new website or add a host header to an existing IIS 7 server from code?

I looked and couldn't find a working example?

+1


a source to share


2 answers


One solution would be to create a custom HttpModule that will work for you, however it requires you to have a DNS that supports wildcards (*). If your DNS doesn't support this, you can look into your own DNS.

However, here's a good article on creating an HttpModule that analyzes the "subdomain" sent and forwarded traffic to the appropriate location. It uses a search engine [to find content with keywords that match a subdomain], but it can be modified to suit your own needs.



http://codebetter.com/blogs/brendan.tompkins/archive/2006/06/27/146875.aspx

[EDIT] Another solution would be to find a DNS provider that offers a programmable DNS service, possibly via a web service. You then programmatically add a subdomain to this DNS when needed from your application. This is a simplified explanation and does not address your business needs. Personally, I prefer the HttpModule parameter for adding subdomains in the application as it requires less modification of the servers involved.

0


a source


What version of .Net are you using?

If you are using .Net 3.0 or 3.5, and if you only need to configure IIS7 (not 6 or 5), check the Microsoft.Web.Administration namespace - it should have everything you need.

If you are using an older version of .net take a look at WMI.



I don't have WMI code for IIS 7 (we have a setup for an intranet application, but it uses an IIS 6 compliant WMI). But here's a link to a tool you can use to figure out the WMI stuff: http://www.microsoft.com/downloads/details.aspx?familyid=2cc30a64-ea15-4661-8da4-55bbc145c30e&displaylang=en It will generate C # ( or vb. net) to manage WMI. For IIS 7, I believe the root WMI namespace is root \ WebAdministration.

Also, take a look at this link, it might help to find out the IIS 7.0 WMI provider using CIM Studio

0


a source







All Articles