{ "Meta": { "Title": "我是标题", "Keywords": "我是关键字", "Description": "我是内容描述" }, }
读取appsettings.json的代码如下:
public static string SeoTitle = DbHelper.ConfigurationManager.Configuration.GetSection("SeoMeta")["Title"]; public static string SeoKeywords = DbHelper.ConfigurationManager.Configuration.GetSection("SeoMeta")["Keywords"]; public static string SeoDescription = DbHelper.ConfigurationManager.Configuration.GetSection("SeoMeta")["Description"];
@page "{handler?}" @model IndexModel @{ ViewData["Title"] = @Html.Raw(Config.SeoTitle); ViewData["Keywords"] = @Html.Raw(Config.SeoKeywords); ViewData["Description"] = @Html.Raw(Config.SeoDescription); }
但页面编译后,所有中文字全部变成了乱码?请教各位,如何解决此问题?在线等
最佳解决方案
用记事本打开appsettings.json 文件,另存为-编码选择UTF-8,保存即可