Firstly,System.Configuration.ConfigurationManager is used in .net framework rather than .net core.In.net core,we usually configure in appsettings.json.You can refer to the official link.Here is a demo:
Startup.cs:
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
...
services.AddSingleton<IConfiguration>(Configuration);
}
appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "data source=exmaple;initial catalog=example;persist security info=True;user id=example;password=example"
},
"myKey": "myValue"
}
TestController:
public class TestController : Controller
{
IConfiguration _iconfiguration;
public TestController(IConfiguration iconfiguration)
{
_iconfiguration = iconfiguration;
}
public IActionResult TestData() {
ViewBag.Data = _iconfiguration.GetSection("myKey").Value;
return View();
}
}
TestData.cshtml:
<p> @ViewBag.data</p>
result:

tag properly.
– Arib Yousuf Mar 02 '21 at 09:21