locked
IIS reading using C# RRS feed

  • Question

  • Hello,

    I want to read IIS websites names and their respective information like Virtual Path,physical path etc..

    Is there any functions or API available in C# to do the same?

    Thank you!!

    Thursday, June 28, 2012 10:40 AM

Answers

All replies

  • Hi,

    Never used but you could try : http://msdn.microsoft.com/en-us/library/aa347649(v=vs.90).aspx


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Thursday, June 28, 2012 10:55 AM
  • Try This

    using (ServerManager serverManager = new ServerManager()) 
    {   
      var sites = serverManager.Sites;  
    foreach (Site site in sites) 
    {           
       Console.WriteLine(site.Name); // This will return the WebSite name 
    } 


    With Thanks and Regards
    Sambath Raj.C
    click "Proposed As Answer by" if this post solves your problem or "Vote As Helpful" if a post has been useful to you
    Happy Programming!

    Thursday, June 28, 2012 11:00 AM
  • Try This

    using (ServerManager serverManager = new ServerManager()) 
    {   
      var sites = serverManager.Sites;  
    foreach (Site site in sites) 
    {           
       Console.WriteLine(site.Name); // This will return the WebSite name 
    } 


    With Thanks and Regards
    Sambath Raj.C
    click "Proposed As Answer by" if this post solves your problem or "Vote As Helpful" if a post has been useful to you
    Happy Programming!

    you can use the following property for read all the values

    http://msdn.microsoft.com/en-us/library/system.web.hosting.hostingenvironment_properties.aspx


    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/

    Thursday, June 28, 2012 11:58 AM
  • I want to know how it is possible using DirectoryEntry not using ServerManager.

    Is there any method which retrieves virtual directories for give website name in C#???

    Friday, June 29, 2012 1:22 PM
  • Then http://www.codeproject.com/Articles/99634/Use-C-to-manage-IIS should help to start (and you have a link below to the IIS ADSI provider)...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Marked as answer by Alexander Sun Tuesday, July 3, 2012 8:25 AM
    Friday, June 29, 2012 1:55 PM