My article focuses on how to access and expose such static resources to the client. Now let’s proceed step-by-step to create awareness on how to use static files.
Step 1: Create an empty ASP.NET 5 project.
Open Visual Studio 2015, select an empty project template for creating new ASP.NET application as in the following:

Step 2: Introduce Static File,
Open Visual Studio 2015, select an empty project template for creating new ASP.NET application as in the following:

Step 2: Introduce Static File,
Create a HTML file under wwwroot folder. Below is my sample HTML file named SampleHTML:

Step 3: Configure Middleware,
Middleware are small components that can be combined as part of an application in order to handle HTTP request response pipeline. So in order to serve static files, Midddleware has to be configured by adding static files to the pipeline. And this can be achieved by using extension method named UseStaticFiles in Startup class. But before that, add the required dependency in project.json file highlighted below:

Step 3: Configure Middleware,
Middleware are small components that can be combined as part of an application in order to handle HTTP request response pipeline. So in order to serve static files, Midddleware has to be configured by adding static files to the pipeline. And this can be achieved by using extension method named UseStaticFiles in Startup class. But before that, add the required dependency in project.json file highlighted below:

Next is to update Configure method in Startup class as:

Step 4: Build and run
Build your code. Now type address as http://<your app name>/SampleHTML.html, your page will be rendered as:

Hope you enjoyed playing with static files. The benefit of using static files in such a way is that you need not to put extra effort to save your sensitive static file because if your file is not available at wwwroot, it won’t be rendered to client. Enjoy learning!

NithikaPosted Feb 5, 2016, 10:23 PM
Nice one
Shubham KumarPosted Feb 1, 2016, 2:03 AM
nice one
Sibeesh VenuPosted Feb 1, 2016, 1:13 AM
Nice Share
Ankit BansalPosted Feb 1, 2016, 12:40 AM
nice one..
Shweta LodhaPosted Jan 30, 2016, 8:07 PM
thanks
Manoj KallaPosted Jan 30, 2016, 11:30 AM
Good one
Jaco ZwartsPosted Jan 30, 2016, 10:59 AM
Nice Article
Irfan AcPosted Jan 30, 2016, 7:09 AM
Nice
Debasis SahaPosted Jan 30, 2016, 5:02 AM
Good One..
Muhammad Aqib ShehzadPosted Jan 30, 2016, 2:18 AM
nice share
Santhakumar MunuswamyPosted Jan 30, 2016, 2:15 AM
Thanks for nice share