« Previous Next »

Answered Thread: Delet WebSite whis Microsoft.Web.Administration

Last post 07-01-2009 3:35 AM by surion. 8 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (9 items)

Sort Posts:

  • 06-29-2009, 9:14 AM

    • surion
    • Not Ranked
    • Joined on 05-26-2009, 10:58 AM
    • Posts 7

    Delet WebSite whis Microsoft.Web.Administration

     Hi all,

     

    I'm trying to delet a website on IIS 7.0 on a 2008 server R2, and i don't know how to do that :/

     

    Thx all for your help :)

  • 06-29-2009, 11:24 AM In reply to

    • krolson
    • Top 75 Contributor
    • Joined on 10-06-2008, 10:32 PM
    • Posts 101

    Answered Re: Delet WebSite whis Microsoft.Web.Administration

    There are a few ways to delete a web site using IIS 7.0.

    For example, this page outlines how to delete a website using WMI (under the 6. Delete a Site section):

    http://learn.iis.net/page.aspx/162/managing-sites-with-iis-7039s-wmi-provider/  

    This page explains how to use appcmd.exe to delete a site (under the Manipulating Objects with ADD, SET, and DELETE section):

    http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe/

    You may also delete a site using the UI (inetmgr).

  • 06-29-2009, 11:37 AM In reply to

    • surion
    • Not Ranked
    • Joined on 05-26-2009, 10:58 AM
    • Posts 7

    Re: Delet WebSite whis Microsoft.Web.Administration

    Hi,

    look a example of my class IIS : 

                 Dim serverManager As ServerManager = New ServerManager
                Dim config As Configuration = serverManager.GetApplicationHostConfiguration
                Dim sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
                Dim sitesCollection As ConfigurationElementCollection = sitesSection.GetCollection
                Dim ValeurDeCheck As Boolean = CheckWebSiteExist(True, sitesCollection, "site", "name", _ClientWebSiteName)
                If ValeurDeCheck Then
                    Dim toto As New ServerManager()
                    Dim tata As Site = toto.Sites.Add(_ClientWebSiteName, "http", "*:80:www." + _ClientWebSiteName, _FTP)
                    toto.CommitChanges()
                Else
                    _ObjErrorMessage = "Error in check addWebSiteInIIS()"
                End If

     

    this code create a website, and i don't found the code to delet it :/

     

  • 06-29-2009, 11:53 AM In reply to

    • krolson
    • Top 75 Contributor
    • Joined on 10-06-2008, 10:32 PM
    • Posts 101

    Re: Delet WebSite whis Microsoft.Web.Administration

    Is there a specific reason that you can't use .vbs scripts with WMI to delete the site (the reference in the previous post does have a delete example for this)?  I don't have a lot of experience in this area, but it seems that using scripts or appcmd would allow you to programmatically delete a site. What is it that you are trying to accomplish?

     

  • 06-30-2009, 3:08 AM In reply to

    • surion
    • Not Ranked
    • Joined on 05-26-2009, 10:58 AM
    • Posts 7

    Re: Delet WebSite whis Microsoft.Web.Administration

     I've to make an intranet to add and delet websites. The code must be in VB.Net ... i'm make the code for add a website, but i don't know how to delet it from IIS7.0

  • 06-30-2009, 5:07 AM In reply to

    Re: Delet WebSite whis Microsoft.Web.Administration

  • 06-30-2009, 6:49 AM In reply to

    • surion
    • Not Ranked
    • Joined on 05-26-2009, 10:58 AM
    • Posts 7

    Re: Delet WebSite whis Microsoft.Web.Administration

    Dim serverManager As ServerManager = New ServerManager

    Dim MySite As Site = serverManager.Sites("test.fr")

    Dim tata As SiteCollection = serverManager.Sites.Remove(MySite)

     

     serverManager.Sites.Remove(MySite) return me an error : Expression does not produce a value.

     

     

  • 06-30-2009, 12:58 PM In reply to

    Re: Delet WebSite whis Microsoft.Web.Administration

    As the error indicates the Remove method does not return a value, you should do:

    Dim serverManager As ServerManager = New ServerManager

    Dim MySite As Site = serverManager.Sites("test.fr")

    serverManager.Sites.Remove(MySite)

    serverManager.CommitChanges()

  • 07-01-2009, 3:35 AM In reply to

    • surion
    • Not Ranked
    • Joined on 05-26-2009, 10:58 AM
    • Posts 7

    Re: Delet WebSite whis Microsoft.Web.Administration

    Thx :D

Page 1 of 1 (9 items)
Microsoft Communities