asp net core read appsetting special character

Viewed 2701

I need to read a value in the controller from the appsettings.json file and send it to the view. The value contains some special character, like letter with accent mark, for example "atención".

The problem is that the special character is not shown properly.

In the startup class I do that:

services.AddOptions();
services.Configure<ApplicationSettings(Configuration.GetSection("ApplicationSettings"));

Where ApplicationSettings is a class for hold the configuration values.

And then in the controller:

private IOptions<ApplicationSettings> _settings;
public StudentController(IOptions<ApplicationSettings> settings)
{
    _settings = settings;
}

public IActionResult Index()
{
    var testSetting = _settings.Value.TestSetting;
    return new ObjectResult(testSetting);
}

testStting value has stranger's character instead of accent marks.

Any idea?

Thanks, regards!

0 Answers
Related