How to set a default page to a Windows Azure Web Role App (Silverlight, ASP.NET, etc.)


 

This is a very easy tip, but useful.
As you may know, Windows Azure management portal has not a way to set many things you could do using IIS Management console. But, because most of the IIS 7.x configuration can be also set using XML configuration files, in most of the cases we don’t really need the IIS Manager.
In this case, we can set a default page to a Windows Azure Web Role App (SIlverlight, ASP.NET, etc.) changing the web.config. We just specify the default page within the System.WebServer section:

<defaultDocument>
              <files>                          
                 <clear/>                          
                 <add value=”MySilverlightInitialPage.aspx”/>                     
              </files>             
</defaultDocument>

Then, your named Silverlight or ASP.NET page will be respected as the default document of the web site, and therefore will be served when the client requests for the root URL (http://mysolution.cloudapp.net/).
Very easy!!

In a similar way, we could specify it per folder (not just the root default page). Instead of specifing it by  “System.WebServer”, you gotta specify the label per “location”. For instance:

<location path=”webFolder1″>
        <system.webServer>
            <defaultDocument>
                <files>
                    <add value=”myDefalutPage.aspx” />
                </files>
            </defaultDocument>
        </system.webServer>
    </location>
    <location path=”webFolder2″>
        <system.webServer>
            <defaultDocument>
                <files>
                    <add value=” myDefalutPage.aspx” />
                </files>
            </defaultDocument>
        </system.webServer>
    </location>

You can get more info here:

 http://msdn.microsoft.com/en-us/library/b6x6shw7(v=VS.90).aspx 

Comments (3)

  1. Nel says:

    I would like to ask if the default page I want for my website resides in a sub folder?

    Ex.

    sitename.azurewebsites.net/Account/Login.aspx

    How do I set this as my default document?

  2. Mike Gorgone says:

    What do you do when your domain has a subfolder that you want the .aspx files in.

    Ex.:

    mysolution.cloudapp.net/clientfolder1

    mysolution.cloudapp.net/clientfolder2

    What if any special publish settings do we need to do. The example URL is what users will be using to return to the site(s)

    We are hoping to have separate sub folders that would have been separate virtual dirs in IIS and then each of them have their own default files.

    Not sure how to deal with this in Azure.

  3. David says:

    Solo felicitarte por el gran trabajo que vienes realizando. Sobre todo tu trabajo realizado sobre Arquitectura NCapas DDD

Skip to main content