Setting default page in deployment

Discussion in 'ASP .Net' started by QDL, Oct 31, 2006.

  1. QDL

    QDL Guest

    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
    QDL, Oct 31, 2006
    #1
    1. Advertising

  2. 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.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com

    *************************************************
    Think outside of the box!
    *************************************************
    "QDL" <> wrote in message
    news:45473466$0$13762$...
    > 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
    >
    >
    Cowboy \(Gregory A. Beamer\), Oct 31, 2006
    #2
    1. Advertising

  3. QDL

    QDL Guest

    > 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
    QDL, Oct 31, 2006
    #3
  4. QDL

    QDL Guest

    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
    QDL, Oct 31, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom
    Replies:
    2
    Views:
    388
  2. Benny Ng
    Replies:
    0
    Views:
    4,391
    Benny Ng
    Oct 3, 2005
  3. Gaetan
    Replies:
    3
    Views:
    1,404
    Juan T. Llibre
    Feb 14, 2006
  4. CJ
    Replies:
    1
    Views:
    1,551
    Andrew Thompson
    Oct 29, 2004
  5. Sean Dockery
    Replies:
    3
    Views:
    870
    Sean Dockery
    Jun 21, 2009
Loading...

Share This Page