当前位置:网站首页>ASP.NET Core配置
ASP.NET Core配置
2022-07-26 00:34:00 【51CTO】

第一步:读取配置文件 appsettings.json

appsettings.json和appsettings.Development.json 需要相同的配置,否则调试时会出现错误,比如:乱码

关于.NET Core 读取appSettings配置文件,中文乱码
方法一:
找到 appsettings.Development.json / appsettings.json 使用 Notepad++ 打开文件
选择 转为UTF-8 BOM ,重新运行项目就OK了

方法二:
【工具】【自定义】【命令】【添加命令】【文件】【高级保存选择(V)...】【关闭】
打开【appsettings.json】文件,选择【高级保存选择(V)...】【编码】【Unicode (UTF-8 带签名) - 代码页 65001】


第二步:因为SiteConfig是自定义的配置,需要创建对应配置类来保存配置数据
第三步:创建控制器
引入using Microsoft.Extensions.Configuration; using Core配置.Models;
第四步:视图显示网站信息,代码详情实例
最后呈现效果

边栏推荐
猜你喜欢

Private cloud disk setup

JDBC实现MySQL8.0数据库的增删改查

Tell you the meaning of unit testing from another angle

In order to grasp the redis data structure, I drew 40 pictures (full version)

向左旋转k个字符串(细节)

Mwec: a new Chinese word discovery method based on multi semantic word vector

Hcip day 12

Pikachu target clearance and source code analysis

Hnoi2012 mine construction

找出单身狗(力扣260)
随机推荐
【oops-framework】网络模块WebSocket
[redis] ③ data elimination strategy, pipeline command, publish and subscribe
Nodejs surface longitude
P4047 [JSOI2010]部落划分
[array related methods in numpy]
hcia综合实验
DC-6--vulnhub靶场
How to use if in sql service
Azure Synapse Analytics 性能优化指南(1)——使用有序聚集列存储索引优化性能
Pikachu target clearance and source code analysis
本地电脑架设传奇怎么开外网叫朋友一起玩?
Database tools duel: heidisql and Navicat
Use localdate class to complete calendar design
Flask send verification code logic
SereTOD2022 Track1代码剖析-面向半监督和强化学习的任务型对话系统挑战赛
The way to understand JS: six common inheritance methods of JS
Data driven DDT for automated testing
[redis] ① introduction and installation of redis
typing‘ has no attribute ‘_SpecialForm‘
SQL (basic 2)