Showing posts with label UseStaticFiles. Show all posts
Showing posts with label UseStaticFiles. Show all posts

Friday, February 22, 2019

Adding UseStaticFiles Middleware

The UseStaticFiles is another important middleware which is required to server static HTML, CSS or JavaScript files to the browser. In Asp.Net Core static files are placed in the wwwroot folder. In this example we shall start by adding an index.html file and serve this file to the browser using the UseStaticFiles middleware.

Let us start by adding a static HTML file to the Hello World sample, open the project and right click on the wwwroot folder Add -> New Item, in the list of file types select HTML file, give it a name index.html and create the file. Add some sample text to the file as follows.