locked
create default document in website (IIS ) in c# RRS feed

  • Question

  • User-1885255629 posted

    I am creating iis website through c# code. I am able to create the website, however I would like to remove all default documents (default.htm, default.aspx etc.,) and put in a custom page in that list (firstpage.aspx) -- Please let me know how I can do this

    Tuesday, August 7, 2007 8:04 PM

Answers

  • User-225114762 posted

    It varies slightly depending on if you're running IIS 5, IIS 6 or IIS 7. It would make it much too easy if configuration options stayed in the same place between versions. Go to administrative tools, select Internet Information Server. In IIS 7, select the web server or virtual directory in question, and then choose "Default Document" in the right hand pane. For IIS 5 and 6 it's part of the properties tabs if I recall correctly.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 8, 2007 1:07 AM
  • User1622957740 posted

    You can use directory services to do this in code although it may not work from your Web application because of permissions issues.

    Here's some code that creates or opens a virtual and sets properties the virtual directory. Notice the DefaultDoc towards the bottom of the code:

    http://west-wind.com/weblog/posts/399.aspx

     

    Hope this helps,

    +++ Rick ---

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 10, 2007 5:52 PM

All replies

  • User-225114762 posted

    It varies slightly depending on if you're running IIS 5, IIS 6 or IIS 7. It would make it much too easy if configuration options stayed in the same place between versions. Go to administrative tools, select Internet Information Server. In IIS 7, select the web server or virtual directory in question, and then choose "Default Document" in the right hand pane. For IIS 5 and 6 it's part of the properties tabs if I recall correctly.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 8, 2007 1:07 AM
  • User1622957740 posted

    You can use directory services to do this in code although it may not work from your Web application because of permissions issues.

    Here's some code that creates or opens a virtual and sets properties the virtual directory. Notice the DefaultDoc towards the bottom of the code:

    http://west-wind.com/weblog/posts/399.aspx

     

    Hope this helps,

    +++ Rick ---

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 10, 2007 5:52 PM