Part -5 Serving Static Files in ASP.NET Core: A Complete Guide

Опубликовано: 21 Март 2025
на канале: Code Insights by Surya
231
2

Learn how to serve static files (such as images, CSS, JavaScript, and more) in your ASP.NET Core applications. This guide explains how to configure and manage static file middleware, set up file serving, and handle custom routes, caching, and security for static content in your web applications.

Static file serve from wwwroot folder in asp.net core application
DefaultFilesOptions obj = new DefaultFilesOptions() ;

obj.DefaultFileNames.Clear();

obj.DefaultFileNames.Add("htmlpage.html");

app.UseDefaultFiles(obj);
app.UseStaticFiles();