« Previous Next »

Answered Thread: IIS7 Virtual Directory / Application for Single File

Last post 07-10-2009 7:04 PM by bberardinis. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 07-10-2009, 5:18 PM

    IIS7 Virtual Directory / Application for Single File

    Honestly this should be simple but it has not been.  I had IIS6 and was able to do it just fine.  What I want is a Forward slash page that points to a single file

    ie:  www.website.com/Forum

    The reason for this is that it is more convienent than having people type: www.website.com/Forum.aspx

    This file resides in the same directory as the parent Default.aspx webpage.

    This was entirely possible in IIS6 to create Virtual Directories that linked to specific files.  It DOES NOT seem to be possible in IIS7.  When I create an Application or Virtual Directory with the same path as the website and change the Default Document to point to a specific file.  THIS CHANGES THE DEFAULT DOCUMENT GLOBALLY FOR THE ENTIRE WEBSITE.

    ie if I created an application and pointed it to Forum.aspx, the homepage of my website would now be pointing to Forum.aspx. 

    I hope this is clear because it is very frustrating.  Is there a way to create a forward slash path with a file in the same directory???  I do not want to put the file in a subfolder because it is tied to masterpages and images with relative paths. Also, please do not tell me to post in another forum, I just need a straight forward answer.  Thank you for your help!

  • 07-10-2009, 5:54 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 2,343

    Answered Re: IIS7 Virtual Directory / Application for Single File

    What you are seeing is because IIS uses distributed config files (web.config) for its configuration same as how asp.net used to - now when you change the default document for the /forums app, the change is written to the web.config file where the / app is also pointing and so ends up applying to both - you would be hitting similar issues with asp.net settings in IIS6.  I can think of at least 3 ways to overcome this

    a) use centralized config file for this setting (similar to IIS6) - from an elevated command run - %windir%\system32\inetsrv\appcmd.exe set config "default web site/forums" -section:system.webServer/defaultDocument -+files.[name='forums.aspx'] -commit:apphost
    b) use url-rewrite rules to rewrite the incoming url from /forums to /forums.aspx - note that you may have to take care of relative links in the response since the url at the server is now /forums.aspx rather than /forums/forums.aspx
    c) Copy forums.aspx to another directory and point /forums to it (you were anyway not getting any benefit from forums.aspx being in the same directory since you were executing /forums/forums.aspx)

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 07-10-2009, 7:04 PM In reply to

    Re: IIS7 Virtual Directory / Application for Single File

    Anil,

    Thanks for the response and yes I have noticed what you described with the web.config file.  

    I may try option B.  Its too bad this changed in IIS7 because it was a nice feature to alias web pages.  With IIS6 I was able to create a virtual directory for any file in the root folder but with your recommended "Option C" I really think I will loose all the relative paths of the content in my page.  Anyway, thanks again.  Any other suggestions would be appreciated.

     - Brett

Page 1 of 1 (3 items)
Microsoft Communities