标签:www mon ogg 类库 setting evel 控制 action hosts
{ "Logging": { "LogLevel": { "Default": "Warning" } }, "AppSettings": { "HttpUrl": "http://www.ehongcn.com", "Copyright": "山南远宏科技有限公司" }, "AllowedHosts": "*" }
public class AppSettings { public string HttpUrl { get; set; } public string Copyright { get; set; } }
services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
private readonly AppSettings _appSettings; public HomeController(IOptions<AppSettings> appSettings) { _appSettings = appSettings.Value; } public IActionResult Index() { ViewData["Url"] = _appSettings.HttpUrl; return View(); }
@using Microsoft.Extensions.Options; @using Demo.Common @inject IOptions<AppSettings> Settings @{ ViewData["Title"] = "Privacy Policy"; } <h1>@ViewData["Title"]</h1> <p>版权所属有 @Settings.Value.Copyright.</p>
ASP.NET Core读取appsettings.json配置文件信息
标签:www mon ogg 类库 setting evel 控制 action hosts
原文地址:https://www.cnblogs.com/zhouxiaoyun/p/10769491.html