для привязки значений из Appsettings.json .
Но внезапно, appsettings. Идеально. Я проверил ссылки и привязки DI, но проблема сохраняется. < /P>
Структура папки: < /p>
Код: Выделить всё
.
└── Solution 'AppBot' (2 of 2 projects)/
├── AppBot/
│ ├── Controllers/
│ │ ├── ClinetMessagesController.cs
│ │ ├── HandleUserController.cs
│ │ ├── QuestionController.cs
│ │ └── QueueMessageController.cs
│ ├── appsettings.json
│ ├── Program.cs
├── AppBot.Application/
│ ├── Models/
│ │ └── ApplicationSettings.cs
│ └── Services/
│ └── SendMessages
Код: Выделить всё
ApplicationSettings.cs
Код: Выделить всё
public class ApplicationSettings
{
public string InfobipBaseURL { get; set; }
public string InfobiptemplateMethodURL { get; set; }
public string InfobipMethodURL { get; set; }
public string InfobipAuthKey { get; set; }
public string ClientMessageAPIKey { get; set; }
public string RegisteredNumber { get; set; }
public string WebHookUrl { get; set; }
}
< /code>
SendMessage.cs
Код: Выделить всё
public class SendMessage : ISendMessage
{
private readonly ApplicationSettings _appSettings;
private readonly string _connectionString;
public SendMessage(IOptions appSettings, IConfiguration config)
{
_appSettings = appSettings.Value; //
appsettings.json
Код: Выделить всё
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"DefaultConnection": "..."
},
"APIConstants": {
"InfobipBaseURL": "..",
"InfobiptemplateMethodURL": "..",
"InfobipMethodURL": "...",
"InfobipAuthKey": "...",
"ClientMessageAPIKey": "...",
"RegisteredNumber": "....",
"WebHookUrl": "..."
},
"AllowedHosts": "*"
}
< /code>
What I've tried:
[list]
[*]Clean/rebuild solution
[*]Deleted bin
Код: Выделить всё
obj
[*] подтвержденные имена классов и ключей точно соответствуют
[*] Set appsettings.json к «скопируйте, если новый»
[*] Внедренные приложения к основному проекту - нет эффекта
[*] Все еще null
[/list]
Подробнее здесь: https://stackoverflow.com/questions/796 ... alues-like