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:
TODO: Search for the server number <---------*
Dim vRoot = GetObject("IIS://LocalHost/W3svc/1/Root/" & _
Me.Context.Parameters.Item("dir"))
vRoot.AuthBasic = False
vRoot.Authanonymous = False
vRoot.AuthNTLM = True
vRoot.SetInfo()
Just in case
How to create an installer class:
- On the File menu, point to New, and then choose Project.
- 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.
- Click OK to close the dialog box.
- On the Project menu, choose Add New Item.
- In the Add New Item dialog box, choose Installer Class. In the Name box, type IISCustomAction.
- Click OK to close the dialog box.
How to create a deployment project for your WebProject:
- On the File menu, choose Add Project, New Project..
- 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.
- Click OK to close the dialog box.
- In the Properties window, select the ProductName property and type IIS Virtual Installer.
- In the File System Editor, select Application Folder. On the Action menu, choose Add, Project Output.
- 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:
- Right click the IIS Virtual Installer Web Setup project in Solution Explorer. On the View menu, point to Custom Actions.
- In the Custom Actions Editor, select the Install node. On the Action menu, choose Add Custom Action.
- In the Select item in the project dialog box, double-click the Application Folder.
- Select the Primary output from the IISCustomAction(Active) item, then click OK to close the dialog box.
- In the Properties window, select the CustomActionData property and type /dir=[TARGETVDIR].
- 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.