When working with IIS 7.5 on Windows 7, you'll notice that accessing http://localhost
displays the default IIS 7 welcome page. This occurs because the "Default Web Site" points to C:\inetpub\wwwroot
by default. While this is fine for initial setup, most developers want to serve their actual application when hitting the root URL.
In IIS terminology:
- Web Site: A container that binds to specific IP/port/hostname combinations
- Application: A virtual directory within a site that represents a distinct web app
Your actual need is to make one of your applications the default content source for the "Default Web Site".
Instead of redirects (which cause issues with asset paths), configure IIS to use your application as the default content:
- Open IIS Manager (
inetmgr
) - Select "Default Web Site"
- Double-click "Default Document"
- Remove "iisstart.htm" and add your application's default page (e.g., "index.html")
For more complex scenarios where you want to preserve the original structure but redirect to an application:
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="approot/default.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
For complete control over the redirection while maintaining proper asset paths:
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to App" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="localhost" />
<add input="{REQUEST_URI}" pattern="^/$" />
</conditions>
<action type="Rewrite" url="/yourapp/" />
</rule>
</rules>
</rewrite>
</system.webServer>
For development environments, consider these approaches in order of preference:
- Change the physical path of "Default Web Site" to point to your application
- Modify the default document list
- Use URL rewrite rules
- Create a new site bound to localhost and disable the default one
When you install IIS 7.5 on Windows 7, the default configuration serves the IIS welcome page from C:\inetpub\wwwroot\iisstart.htm
when accessing http://localhost
. This occurs because:
- The "Default Web Site" is bound to port 80
- It has a physical path pointing to
wwwroot
- No application is set as default document
The proper way to change this behavior is through IIS Manager:
- Open IIS Manager (
inetmgr
) - Select "Default Web Site" in the left panel
- Double-click "Default Document" feature
- Remove "iisstart.htm" from the list
- Add your application's startup document (e.g., "index.aspx")
For applications that don't use physical files (like MVC apps), you'll need to:
// In Application_Start of Global.asax
protected void Application_Start()
{
RouteTable.Routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
For more control, install the URL Rewrite module and add this to your web.config
:
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to App" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/YourAppName" />
</rule>
</rules>
</rewrite>
</system.webServer>
- Application Pool identity must have proper permissions
- Firewall settings may block non-standard ports
- Hosts file (
C:\Windows\System32\drivers\etc\hosts
) shouldn't interfere - Check bindings in IIS to ensure no port conflicts