Disabling unnecessary features
Most ASP.NET Core web application features are useful, but some can be unnecessary or sometimes even harmful. Web developers must consider whether a web server or application functionality needs to be enabled in code. We need to remove some features to keep our ASP.NET Core web applications secure.
In this recipe, we are going to remove the Server
HTTP header to prevent web server information disclosure.
Getting ready
We will use the Online Banking app we used in the previous recipe. Using Visual Studio Code, open the sample Online Banking app folder at \Chapter07\unnecessary-features\before\OnlineBankingApp\
.
You can perform the steps in this folder to disable unnecessary features in this recipe.
How to do it…
Let's take a look at the steps for this recipe:
- From the starting exercise folder, launch Visual Studio Code by typing following command:
code .
- Open
Program.cs
and notice the value of one of the properties...