Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I automate creating a .NET web application in IIS?

I need to deploy a web application on several laptops (although it is a web application, it is intended to run via localhost only - thus the need to deploy on several different machines).

Normally I would go to IIS and right click a directory to create a web application, but I would very much like to automate this leg of the installation. Can it be done?

I want to use IIS, but I want to create the web application automatically without opening the IIS Microsoft Management Console (MMC).

like image 671
Ian G Avatar asked Nov 24 '08 10:11

Ian G


People also ask

Does .NET use IIS?

Most commonly, IIS is used to host ASP.NET web applications and static websites. It can also be used as an FTP server, host WCF services, and be extended to host web applications built on other platforms such as PHP.


4 Answers

I can suggest you to take a look at this link if you are deploying on IIS 6 or at this one if it is IIS 7 (I could recommend Mike Volodarsky's blog for any information on IIS 7 in general).

It should be quite simple for you to write some batch file to automate a site creation.

Example:

  • IIS6 : iisweb /create C:\Rome "My Vacations" /d www.reskit.com /dontstart
  • IIS7 : %windir%\system32\inetsrv\AppCmd ADD SITE /name:MyNewSite /bindings:http/*:81: /physicalPath:c:\inetpub\mynewsite
like image 165
Enes Avatar answered Sep 20 '22 18:09

Enes


You're really asking two different questions. First, why reinvent the wheel? In all likelihood, the laptops are already capable of running IIS - it's available on all "modern" Windows versions with the possible exception of Vista Home. Second, a VS.NET installer can easily target and automate an install to IIS. If you use Wix or some other third party installer it will require more manual work but can still be done.

Edit: In re-reading your question, that sounds like what you're really asking - you already knew IIS was available on the target computers, but just didn't want to manually install on each computer. Correct? In that case, definitely look at the VS.NET setup project - they have a built-in target for IIS deployment.

like image 43
GalacticCowboy Avatar answered Sep 21 '22 18:09

GalacticCowboy


You can look inside the Cassini Sample Web Server (comes with source):

The ASP.NET Cassini Web Server Sample is a sample web server written using the Microsoft® .NET® Framework, and demonstrates hosting ASP.NET using the ASP.NET hosting APIs (System.Web.Hosting).

like image 29
gimel Avatar answered Sep 23 '22 18:09

gimel


You could use the system.DirectoryServices class e.g.

http://www.gafvert.info/iis/article/cs_create_website_iis6.htm

like image 26
ca8msm Avatar answered Sep 22 '22 18:09

ca8msm