Click here to Skip to main content
Click here to Skip to main content

Deploy IIS settings along with your Web Project

By , 15 Nov 2006
 

Introduction

One of the issues that you need to consider as you plan for how to deploy your ASP.NET applications is how to deploy IIS settings along with your solution. This is a brief example of how to set the Virtual Directory Authentication Settings.

Using the code

Add the following code to the CustomAction class' Install method:

REM *******************************************************
REM Set IIS Virtual Dir Authentication Settings' 

TODO: Search for the server number <---------*
Dim vRoot = GetObject("IIS://LocalHost/W3svc/1/Root/" & _
            Me.Context.Parameters.Item("dir")) 

' Set authentication method for the Virtual Dir

vRoot.AuthBasic = False     ' Unset Basic Authentication
vRoot.Authanonymous = False ' Unset Anonymous Authentication
vRoot.AuthNTLM = True       ' Set Integrated Windows Authentication

' Actually apply it 
vRoot.SetInfo()

Just in case

How to create an installer class:

  1. On the File menu, point to New, and then choose Project.
  2. In the New Project dialog box, select Visual Basic Projects in the Project Type pane, and then choose Class Library in the Templates pane. In the Name box, type IISCustomAction.
  3. Click OK to close the dialog box.
  4. On the Project menu, choose Add New Item.
  5. In the Add New Item dialog box, choose Installer Class. In the Name box, type IISCustomAction.
  6. Click OK to close the dialog box.

How to create a deployment project for your WebProject:

  1. On the File menu, choose Add Project, New Project..
  2. In the Add Project dialog box, select Setup and Deployment Projects in the Project Type pane, and then choose Web Setup Project in the Templates pane. In the Name box, type IIS Virtual Installer.
  3. Click OK to close the dialog box.
  4. In the Properties window, select the ProductName property and type IIS Virtual Installer.
  5. In the File System Editor, select Application Folder. On the Action menu, choose Add, Project Output.
  6. In the Add Project Output Group dialog box, select the primary output for the WebProject project. Click OK to close the dialog box.

How to create a custom action for your Deployment Project:

  1. Right click the IIS Virtual Installer Web Setup project in Solution Explorer. On the View menu, point to Custom Actions.
  2. In the Custom Actions Editor, select the Install node. On the Action menu, choose Add Custom Action.
  3. In the Select item in the project dialog box, double-click the Application Folder.
  4. Select the Primary output from the IISCustomAction(Active) item, then click OK to close the dialog box.
  5. In the Properties window, select the CustomActionData property and type /dir=[TARGETVDIR].
  6. On the Build menu, choose Build DBCustomActionInstaller.

Points of Interest

That's it! It works for me. Of course, this is simple, but maybe I've saved you some time searching for it. Now just think of a bit, to get profit off IIS Admin Objects.

Also check out A C Sharp alternative for Visual Basic GetObject function.

History

  • Nov. 14, 2006 - Initial version.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

rmortega77
Software Developer CIMEX S.A.
Cuba Cuba
Member
Rodolfo Ortega is a Cuban Computer Scientist. He works as IT Auditor for the CIMEX S.A. subsidiary in Holguin, Cuba. He lives and works in Holguin, in the eastern part of the island of Cuba.

You can contact him at rodolfom[]cimex.com.cu for any personal message: Ideas on new articles, bibliography about new APIs, questions, are wellcome.

Submit questions related with current article to the article forum.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralDirectory ServicesmemberMember 357722813 Dec '10 - 5:18 
I suggest you to use the System.DirectoryServices to achieve this, like the following:
 
            //Set IIS Virtual Dir Authentication Settings

            //TODO: Search for the server number*
            var vRoot = new DirectoryEntry("IIS://LocalHost/W3svc/1/Root/" + this.Context.Parameters["dir"]);
 
            // Set authentication method for the Virtual Dir
            vRoot.InvokeSet("AuthBasic", false);    // Unset Basic Authentication
            vRoot.InvokeSet("Authanonymous", false); // Unset Anonymous Authentication
            vRoot.InvokeSet("AuthNTLM", true);       // Set Integrated Windows Authentication

 
            // Actually apply it 
            vRoot.Invoke("SetInfo");
 
The installer must send the number of the server, as you choose it on a list, but I haven't found how yet.
 
Att,
Marcos Jr.
QuestionC# version of GetObjectmembertprakash17 Jan '07 - 22:45 
Could you please let me know how to initialize GetObject in c#;
 
Thanks
 
prakash
 
prakash
QuestionChanging physical location of virtual dir?memberrobrich15 Nov '06 - 13:38 
Can this technique also be used to change the physical location of the IIS virtual dir as well? For example, I don't want it installed in c:\Inetpub\wwwroot\myapp. I'd rather it installed in c:\My Folder\myapp.
AnswerRe: Changing physical location of virtual dir?memberrmortega7716 Nov '06 - 11:21 
Yes, but rather using a Web Setup Deployment project, we should use an Application Setup project to create the physical path, and content, and later with a Custom Action, create the virtual dir, using IIS Admin Objects. I posted a new article on this subject look at: WebToInstall
 
,-7

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 15 Nov 2006
Article Copyright 2006 by rmortega77
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid