asp.net-core-configuration

ASP.NET Core Options pattern with name split by single underscore

旧城冷巷雨未停 提交于 2021-01-29 03:06:40
问题 I am trying to load my app settings with ASP.NET Core Options pattern. The appsettings.json contains: { "TEst": "hello", "TEST_ABC": "2" } POCO class: public class AppSetting { public string Test { get; set; } public string TestAbc { get; set; } } Bind to configuration: services.Configure<AppSetting>(Configuration); While access AppSetting instance in controller, I can only get config Test as hello . TestAbc is set to null . It seems Options pattern couldn't convert this kind of naming

ASP.NET Core Options pattern with name split by single underscore

我们两清 提交于 2021-01-29 02:57:38
问题 I am trying to load my app settings with ASP.NET Core Options pattern. The appsettings.json contains: { "TEst": "hello", "TEST_ABC": "2" } POCO class: public class AppSetting { public string Test { get; set; } public string TestAbc { get; set; } } Bind to configuration: services.Configure<AppSetting>(Configuration); While access AppSetting instance in controller, I can only get config Test as hello . TestAbc is set to null . It seems Options pattern couldn't convert this kind of naming

Configuration.GetSection returns null value

眉间皱痕 提交于 2019-12-23 20:23:15
问题 I cannot get my Configuration.GetSection to return data in .Value . I think I implemented all the suggestions from this question, but still can't get it to work. appsettings.json { "AmazonSettings": { "BaseUrl": "https://testing.com", "ClientID": "123456", "ResponseType": "code", "RedirectUri": "https://localhost:44303/FirstTimeWelcome" }, } Startup: public IConfiguration Configuration { get; } public Startup(IHostingEnvironment env) { //Set up configuration sources. var builder = new

Getting ConnectionStrings config settings from appsettings.json

家住魔仙堡 提交于 2019-12-11 15:49:42
问题 In my repository class, I have my Config object and looks like my connection string is under: Config > Providers > Microsoft.Configuration.Json.JsonConfigurationProvider > Data > ConnectionStrings.myConnectionString This is what my appsettings.json looks like: { "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Warning" } }, "ConnectionStrings": { "myConnectionString": details..." } } I'm trying to read myConnectionString as follows which is not working: var cs = _config

asp.net core identity does not redirect to correct logon pages

会有一股神秘感。 提交于 2019-12-11 10:59:22
问题 Configured this way it is not working. services .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.ExpireTimeSpan = TimeSpan.FromMinutes(5); options.LoginPath = $"/logon"; options.LogoutPath = $"/logoff"; options.AccessDeniedPath = $"/accessdenied"; options.SlidingExpiration = true; }) configured this way it is working : services.ConfigureApplicationCookie(options => { options.Cookie.Name = "Caldr.Auth"; options.LoginPath = $"/logon"; options