Setting default page in deployment

Q

QDL

Hello everyone,

is there a way to programmatically set the default document from a
deployment project for ASP.NET. My default page is named default.htm and I'd
like to set it as the topmost default document in IIS site properties using
the deployment project, is this possible? Tried to google but found no
answer.

TIA
Paolo
 
C

Cowboy \(Gregory A. Beamer\)

You can do this by exporting the IIS settings and actually installing them
on the server in question. I do not have a working example right now, but
will see if I have anything written up on it.
 
Q

QDL

You can do this by exporting the IIS settings and actually installing them
on the server in question. I do not have a working example right now, but
will see if I have anything written up on it.

Thanx Cowboy for answering, will appreciate if you have a sample but anyway,
you pointed me the right way... I thought there was something in the
Deployment project to obtain that but I was wrong...

Thanx
Paolo
 
Q

QDL

I answer myself as I found the way and may be helpful to some1:

1. In deployment project add CustomAction for OnCommit specify
InstallerClass=True and add parameter /vdir="[TARGETVDIR]"

2. Add an installer class to your aspnet project and insert this override:

Private Const EnableDefaultDoc = &H40000000&

Protected Overrides Sub OnCommitted(ByVal savedState As
System.Collections.IDictionary)
Dim folderRoot, vdir As DirectoryEntry
Dim vdirname As String

Try
vdirname = Me.Context.Parameters("vdir")

folderRoot = New DirectoryEntry("IIS://localhost/W3SVC/1/Root")
folderRoot.RefreshCache()

vdir = folderRoot.Children.Find(vdirname, folderRoot.SchemaClassName)

vdir.Properties("DirBrowseFlags").Value =
vdir.Properties("DirBrowseFlags").Value Or EnableDefaultDoc
vdir.Properties("DefaultDoc").Value = "default.htm"

vdir.CommitChanges()
folderRoot.CommitChanges()
Catch ex As Exception
Finally
If (Not vdir Is Nothing) Then
vdir.Close()
End If

If (Not folderRoot Is Nothing) Then
folderRoot.Close()
End If
End Try
End Sub

This will enable default documents and add default.htm as the only default
document. Of course can be changed.

Hope someone will be helped by this

Paolo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top