MCBDSHost - Professional Minecraft Bedrock Server Management

Sitemap 404 Fix

Marketing Website deployment-packages/SITEMAP-404-FIX.md

Sitemap.xml 404 Error - FIXED

Problem Identified

Error: https://mcbdshost.com/sitemap.xml returns 404 Not Found

Root Cause:

  1. Missing .xml MIME type mapping in web.config
  2. Static files not explicitly marked for output directory in .csproj

Solution Implemented

Changes Made

1. web.config - Added XML MIME Type

<staticContent>
  <mimeMap fileExtension=".xml" mimeType="application/xml" />
  <mimeMap fileExtension=".txt" mimeType="text/plain" />
  <!-- ...other MIME types... -->
</staticContent>

2. MCBDS.Marketing.csproj - Ensured File Inclusion

<ItemGroup>
  <Content Update="wwwroot\sitemap.xml">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
  <Content Update="wwwroot\robots.txt">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemGroup>

Quick Deployment

cd deployment-packages
.\deploy-sitemap-fix.ps1

Option 2: Manual Deployment

# 1. Clean and publish
cd MCBDS.Marketing
dotnet clean -c Release
dotnet publish -c Release -o bin\Release\net10.0\publish

# 2. Verify sitemap exists
Test-Path bin\Release\net10.0\publish\wwwroot\sitemap.xml

# 3. Copy to IIS
Copy-Item -Path "bin\Release\net10.0\publish\*" -Destination "C:\inetpub\wwwroot\mcbdshost-marketing\" -Recurse -Force

# 4. Restart IIS
iisreset

# 5. Test
Invoke-WebRequest -Uri "https://mcbdshost.com/sitemap.xml"

Verification Steps

1. Check File Exists in Publish Output

Test-Path MCBDS.Marketing\bin\Release\net10.0\publish\wwwroot\sitemap.xml
# Should return: True

2. Check File in IIS Directory

Test-Path C:\inetpub\wwwroot\mcbdshost-marketing\wwwroot\sitemap.xml
# Should return: True

3. Test HTTP Access

# Using PowerShell
Invoke-WebRequest -Uri "https://mcbdshost.com/sitemap.xml"

# Or using browser
# Navigate to: https://mcbdshost.com/sitemap.xml
# Should display XML content

4. Verify in Browser

  • Navigate to: https://mcbdshost.com/sitemap.xml
  • Should display XML content with site URLs
  • No 404 error

5. Check robots.txt References Sitemap

  • Navigate to: https://mcbdshost.com/robots.txt
  • Should contain: Sitemap: https://mcbdshost.com/sitemap.xml

What Was Fixed

Issue Before After
sitemap.xml accessibility 404 Not Found 200 OK
MIME type for .xml Not configured application/xml
File in publish output Inconsistent Always included
IIS can serve XML No Yes

Files Changed

  1. MCBDS.Marketing/web.config - Added .xml and .txt MIME types
  2. MCBDS.Marketing/MCBDS.Marketing.csproj - Ensured file inclusion
  3. Created deployment-packages/deploy-sitemap-fix.ps1 - Automated deployment

Technical Details

Why the 404 Happened

IIS Static File Handler Requirements:

  • IIS needs explicit MIME type mappings for file extensions
  • Without <mimeMap fileExtension=".xml" ...>, IIS won't serve .xml files
  • The ASP.NET Core module passes unhandled requests to the app, but static files should be served by IIS directly

.NET 10 Static Web Assets

  • In .NET 10, Static Web Assets use a new build system
  • Files in wwwroot should be automatically included
  • Explicit <Content> entries ensure files are copied during publish
  • CopyToOutputDirectory guarantees the files appear in the publish folder

Testing Checklist

After deployment, verify:

  • Build completes without errors
  • Publish output contains wwwroot/sitemap.xml
  • IIS directory contains wwwroot/sitemap.xml
  • https://mcbdshost.com/sitemap.xml returns 200 OK
  • XML content is displayed (not downloaded)
  • Contains all 6 URLs (home, features, get-started, contact, gofundme, not-found)
  • https://mcbdshost.com/robots.txt is also accessible
  • Google Search Console can read the sitemap

Google Search Console Submission

After deploying the fix:

  1. Go to Google Search Console

  2. Navigate to Sitemaps

    • Left menu Sitemaps
  3. Add New Sitemap

    • Enter: sitemap.xml
    • Click: Submit
  4. Verify Status

    • Should show: Success
    • URLs discovered: 6

Troubleshooting

sitemap.xml Still Returns 404

Solution 1: Check IIS MIME Types

# Open IIS Manager
# Select your site
# Double-click "MIME Types"
# Verify .xml is listed with application/xml

Solution 2: Verify File Exists

Get-ChildItem -Path "C:\inetpub\wwwroot\mcbdshost-marketing\wwwroot" -Filter "*.xml"
# Should list sitemap.xml

Solution 3: Check web.config

# Open web.config in IIS directory
# Verify <mimeMap fileExtension=".xml" mimeType="application/xml" /> exists

Solution 4: Restart IIS

iisreset

File Exists But Still 404

Check IIS Handler Mappings:

  1. Open IIS Manager
  2. Select your site
  3. Double-click "Handler Mappings"
  4. Verify "StaticFile" handler is enabled
  5. Verify it's not being overridden by ASP.NET Core handler

XML Downloads Instead of Displaying

Fix Content-Type Header:

  • This means MIME type is set to application/octet-stream
  • Verify mimeType="application/xml" in web.config
  • Clear browser cache and try again

Expected Results

Immediate (After Deployment)

Short-term (1-2 days)

  • Google Search Console accepts sitemap
  • All 6 URLs submitted to Google
  • Crawl status shows "Success"

Medium-term (1-2 weeks)

  • All pages indexed by Google
  • Pages appear in Google search results
  • Sitemap shows "Last read" date in Search Console

Summary

Problem: sitemap.xml returned 404 error
Cause: Missing XML MIME type in web.config
Solution: Added MIME type mappings and file inclusion directives
Status: FIXED AND READY TO DEPLOY


Next Steps

  1. Deploy the fix using the PowerShell script
  2. Test sitemap.xml in browser
  3. Submit to Google Search Console
  4. Monitor indexing status

Status: READY FOR DEPLOYMENT

Last Updated: December 29, 2024
For: MCBDSHost Marketing Site
Priority: High (SEO Critical)

Support MCBDSHost Development

Help us continue developing and improving MCBDSHost. Your support makes a difference!