Output encoding using JavascriptEncoder
Web development wouldn't be complete without JavaScript. It has always been the de facto scripting language for developing web applications, and it is used for multiple purposes, from animation to validating input from the client side. There will be instances where developers will mix JavaScript code blocks with C# code or the Razor syntax within ASP.NET Core pages. This approach makes escaping outp`ut alongside JavaScript necessary, and it also prevents JavaScript code from being injected with malicious functions.
In this recipe, you will learn how to use JavascriptEncoder
to escape output in JavaScript.
Getting ready
Using Visual Studio Code, open the sample Online Banking app folder at \Chapter01\output-encoding-js\before\OnlineBankingApp
.
How to do it…
Let's take a look at the steps for this recipe:
- Launch Visual Studio Code and open the starting exercise folder by typing the following command:
code...