If your ASP.NET Core app shows a blank browser tab or a fallback symbol instead of your brand, the icon is usually missing from the rendered <head> or stored outside the folder exposed as static content. An ASP.NET Core favicon needs two pieces: an icon file under wwwroot and a link declaration in the shared layout.

That distinction matters. Placing favicon.ico in the project root does not put it under wwwroot, and adding a file to wwwroot does not automatically add it to every page. The steps below cover MVC and Razor Pages apps that use a conventional shared layout.

Prerequisites

If the app has separate public, account, or admin layouts, repeat the markup step in each one. An API-only app has no page head to configure; add the favicon to its landing page or documentation host instead.

Add an ASP.NET Core favicon step by step

  1. Prepare a small icon set

    Create this folder structure:

    wwwroot/
      favicon.ico
      icons/
        favicon.svg
        favicon-32x32.png
        apple-touch-icon.png

    Use an ICO containing 16, 32, and 48 pixel images, a 32 pixel PNG, and a simple SVG. Add a 180 pixel Apple touch icon if users may save the site to a home screen. If your source is a logo or PNG, Mzu favicondl can create the ICO, PNG, and SVG variants without changing the source file.

  2. Confirm that static files are served

    ASP.NET Core serves files from wwwroot through its static-file middleware. If your app already loads CSS or images from that folder, this step is probably done. Otherwise, ensure the pipeline includes:

    var app = builder.Build();
    
    app.UseStaticFiles();
    
    // Keep your existing routing and endpoint registrations below.

    Add the call once. If a middleware entry already exists, do not register it twice.

  3. Add the links inside the shared head

    Open Views/Shared/_Layout.cshtml for MVC or Pages/Shared/_Layout.cshtml for Razor Pages. Place these elements inside <head>, beside the stylesheet links:

    <link rel='icon' href='~/favicon.ico' sizes='16x16 32x32 48x48'>
    <link rel='icon' href='~/icons/favicon-32x32.png' type='image/png' sizes='32x32'>
    <link rel='icon' href='~/icons/favicon.svg' type='image/svg+xml' sizes='any'>
    <link rel='apple-touch-icon' href='~/icons/apple-touch-icon.png' sizes='180x180'>

    The rel='icon' form identifies an external icon resource, as defined by the HTML link-type documentation. The Razor ~/ paths keep the URLs correct when the app is hosted below a subpath. If your layout has no <head>, add one before inserting the links.

  4. Keep a root ICO fallback

    The file at wwwroot/favicon.ico is available at /favicon.ico. As a compatibility measure, keep that file and the explicit ICO link: browser requests for the conventional root path then have a valid response even if a page template is incomplete.

  5. Run the app and check each response

    Start the site with dotnet run, open its local URL, and open browser developer tools. Select the Network panel, filter for favicon, and reload the page. Any icon requests shown there should return successfully with image content types rather than 404 responses. Use View Source to confirm that the four link elements are in the returned HTML, then check that the browser tab displays the intended mark.

  6. Verify the published site

    Deploy the app, inspect the live page source, and repeat the Network check. If the icon works locally but not in production, compare the generated href values with the deployed URL and confirm that the icon files are present in the published output. For an old icon that remains visible, try a private window before investigating a CDN, service worker, or browser favicon cache.

Common pitfalls

If the markup and responses are correct but the tab still shows the wrong icon, work through the broader favicon troubleshooting checklist. For the underlying HTML-only process, see how to add a favicon to a website.

Finish with a clean icon stack

Your ASP.NET Core favicon is ready when the files sit under wwwroot, static-file middleware is active, and the shared layout declares the ICO, PNG, and SVG candidates. Keep the root favicon.ico, verify the deployed responses, and only then treat the tab icon as complete.