IIS Favicon Configuration Guide
Master favicon setup on Microsoft IIS: web.config configuration, MIME types, static content caching, compression, and Windows Server best practices.
Quick Setup Guide
1. File Location
Place favicons in wwwroot or site root folder
2. MIME Types
Configure in IIS Manager or web.config
3. Caching
Set cache headers for optimal performance
Basic IIS Favicon Setup
Step-by-Step Configuration
Step 1: File Placement
Place your favicon files in the appropriate directory:
C:\inetpub\wwwroot\YourSite\
favicon.ico
favicon-16x16.png
favicon-32x32.png
favicon-96x96.png
favicon-512x512.png
apple-touch-icon.png
android-chrome-192x192.png
android-chrome-512x512.png
site.webmanifestStep 2: Verify Permissions
Ensure IIS application pool identity has read access:
- Right-click favicon.ico ? Properties ? Security
- Add
IIS AppPool\YourAppPoolNamewith Read permissions - Or use
IUSRaccount for simpler setup
Quick Test: Access
http://yoursite.com/favicon.ico directly in browser to verify file is served correctly.
MIME Type Configuration
Configure Static Content Types
Method 1: IIS Manager (GUI)
- Open IIS Manager
- Select your website
- Double-click "MIME Types"
- Click "Add..." in right panel
- Add missing MIME types from table below
| Extension | MIME Type | Required |
|---|---|---|
.ico |
image/x-icon |
Yes |
.png |
image/png |
Yes |
.svg |
image/svg+xml |
Recommended |
.webmanifest |
application/manifest+json |
PWA |
Method 2: web.config (Recommended)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<!-- ICO files -->
<remove fileExtension=".ico" />
<mimeMap fileExtension=".ico" mimeType="image/x-icon" />
<!-- PNG files (usually pre-configured) -->
<remove fileExtension=".png" />
<mimeMap fileExtension=".png" mimeType="image/png" />
<!-- SVG files -->
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<!-- Web App Manifest -->
<remove fileExtension=".webmanifest" />
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
</staticContent>
</system.webServer>
</configuration>Note:
<remove> prevents duplicate MIME type errors if entry already exists.
Caching & Performance
Optimize Favicon Delivery
Complete web.config with Caching
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<!-- MIME Types -->
<staticContent>
<remove fileExtension=".ico" />
<mimeMap fileExtension=".ico" mimeType="image/x-icon" />
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<remove fileExtension=".webmanifest" />
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
<!-- Enable client caching for 1 year -->
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
</staticContent>
<!-- Custom Headers for Favicon -->
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="public, max-age=31536000, immutable" />
</customHeaders>
</httpProtocol>
<!-- Enable Static Compression -->
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
</system.webServer>
</configuration>Location-Specific Caching (Advanced)
Apply different cache rules for favicons only:
<configuration>
<!-- Favicon-specific caching -->
<location path="favicon.ico">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
</staticContent>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="public, max-age=31536000" />
</customHeaders>
</httpProtocol>
</system.webServer>
</location>
<!-- All PNG favicons -->
<location path="favicon-16x16.png">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
</staticContent>
</system.webServer>
</location>
</configuration>GZIP Compression
Enable Static Compression
IIS Manager Configuration
- Open IIS Manager
- Select your server or website
- Double-click "Compression"
- Check "Enable static content compression"
- Click "Apply"
web.config Compression Settings
<system.webServer>
<urlCompression
doStaticCompression="true"
doDynamicCompression="false"
dynamicCompressionBeforeCache="false" />
<!-- Add ICO and SVG to compression types (applicationHost.config) -->
<httpCompression>
<staticTypes>
<add mimeType="image/svg+xml" enabled="true" />
<add mimeType="image/x-icon" enabled="true" />
</staticTypes>
</httpCompression>
</system.webServer>Note: ICO compression may not significantly reduce file size. SVG files benefit greatly from GZIP compression.
URL Rewrite for Favicon
Redirect Missing Favicon Requests
Install URL Rewrite Module
Download from: Microsoft IIS URL Rewrite
web.config Rewrite Rules
<system.webServer>
<rewrite>
<rules>
<!-- Redirect old favicon.ico to new location -->
<rule name="Redirect Favicon" stopProcessing="true">
<match url="^old-favicon\.ico$" />
<action type="Redirect" url="/favicon.ico" redirectType="Permanent" />
</rule>
<!-- Serve default favicon for missing requests -->
<rule name="Serve Default Favicon" stopProcessing="true">
<match url="^(.*/)?favicon\.ico$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/favicon.ico" />
</rule>
</rules>
</rewrite>
</system.webServer>ASP.NET Core on IIS
.NET Applications Favicon Setup
File Location
Place favicons in wwwroot folder:
YourProject/
wwwroot/
favicon.ico
favicon-16x16.png
favicon-32x32.png
apple-touch-icon.pngProgram.cs Configuration (ASP.NET Core 6+)
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
// Enable static files (includes favicons)
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
{
// Set caching for favicon files
if (ctx.File.Name.Contains("favicon") ||
ctx.File.Name.Contains("apple-touch-icon"))
{
ctx.Context.Response.Headers.Append(
"Cache-Control", "public,max-age=31536000");
}
}
});
app.Run();web.config for ASP.NET Core
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\YourApp.dll" stdoutLogEnabled="false" />
<!-- Static files handled by ASP.NET Core middleware -->
<staticContent>
<remove fileExtension=".ico" />
<mimeMap fileExtension=".ico" mimeType="image/x-icon" />
</staticContent>
</system.webServer>
</configuration>Troubleshooting IIS Favicon Issues
Solutions:
- Verify file exists in physical path (
C:\inetpub\wwwroot\...) - Check IIS application pool identity has Read permissions
- Ensure MIME type is configured for .ico extension
- Check URL Rewrite rules aren't blocking request
- Test direct URL:
http://site.com/favicon.ico
Fixes:
- Clear browser cache (Ctrl+Shift+R)
- Add version query string:
favicon.ico?v=2 - Restart IIS application pool
- Run
iisresetin admin cmd - Check if Output Caching is enabled and reset it
- Verify web.config cache headers
Error:
Solution:
Cannot add duplicate collection entry of type 'mimeMap'
Solution:
- Add
<remove fileExtension=".ico" />before<mimeMap> - Or configure at server level, not site level
- Check parent applicationHost.config for existing entries
Cause: Missing static file handler or incorrect MIME type
Solution:
Solution:
- Ensure Static Content role is installed in IIS
- Verify StaticFileModule is enabled
- Check handler mappings for static files
- Add correct MIME type in web.config
IIS Favicon Best Practices
? Recommendations
- Use web.config for MIME types (portable across servers)
- Set long cache expiration (1 year minimum)
- Enable static compression for SVG files
- Place favicons in
wwwrootor site root - Set proper file permissions (Read for IIS user)
- Use URL Rewrite for legacy paths
- Monitor IIS logs for 404 favicon errors
- Test with IIS Express locally first
? Common Mistakes
- Not configuring MIME types (404 errors)
- Forgetting file permissions for app pool identity
- Placing favicons outside physical path
- Not setting cache headers (poor performance)
- Using dynamic compression for static files
- Blocking favicon in URL Rewrite rules
- Not testing after IIS updates
- Hardcoding server-specific paths
Useful PowerShell Commands
IIS Management Commands
Common IIS Commands
# Reset IIS
iisreset
# Restart specific application pool
Restart-WebAppPool -Name "YourAppPoolName"
# Check if MIME type exists
Get-WebConfigurationProperty -Filter "//staticContent/mimeMap" `
-PSPath "IIS:\Sites\Default Web Site" -Name *
# Add MIME type via PowerShell
Add-WebConfigurationProperty -Filter "//staticContent" `
-PSPath "IIS:\Sites\Default Web Site" `
-Name "." -Value @{fileExtension='.webmanifest'; mimeType='application/manifest+json'}
# Enable static compression
Set-WebConfigurationProperty -Filter "/system.webServer/urlCompression" `
-PSPath "IIS:\Sites\Default Web Site" `
-Name "doStaticCompression" -Value $true
# List all websites
Get-Website
# Get site physical path
(Get-Website -Name "Default Web Site").PhysicalPathTest Favicon Availability
# Test if favicon exists
Test-Path "C:\inetpub\wwwroot\favicon.ico"
# Get favicon file info
Get-ChildItem "C:\inetpub\wwwroot\favicon.ico" | Select-Object Name, Length, LastWriteTime
# Test HTTP response
Invoke-WebRequest -Uri "http://localhost/favicon.ico" -Method Head
# Check MIME type in response
(Invoke-WebRequest -Uri "http://localhost/favicon.ico").Headers["Content-Type"]Generate IIS-Ready Favicons
Create optimized favicon packages ready for Microsoft IIS deployment
Generate Favicons