首先在主目录下建立:Iyibank.Web.json文件
里边的内容如下:
{
"ConnectionStrings": {
"RedisCache": "127.0.0.1:6379"
}
}
在其他需要调用RedisCache的地方调用如下:
var builder = new ConfigurationBuilder().AddJsonFile("Iyibank.Web.json", optional: false, reloadOnChange: true);
var configuration = builder.Build();
var con= configuration.GetConnectionString("RedisCache");