What is Resource File?
A resource file is a XML file that contains a key-value pair as an individual resource that used to:
- Translate into multiple languages.
- Resource values can be dynamically updated, such as page titles, error messages, and label text, once the website is published.
we will show you how to create a Global Resources file in ASP.NET that allows for quick dynamic modifications and supports many languages, as well as how to implement it.
Global resource files can be read from any page or component in the application; however, they must be saved under App_GlobalResources at the application's root.
How to create a resource file?
- In solution explorer, right click on the root of the web application click Add, then click Add ASP.NET folder, then select App_GlobalResources folder
Right click on App_GlobalResources folder and click on add new item
Add new item window, chose Resources file and give it any name with .resx extension
- Fill the resource file with key / value pairs
How to use a resource?
You can access resource values from your ASP.NET code-behind files or views.
<h1> @Resources.Labels.Login </h1>