{ "AppSettings": { "User": "test", "Password": "0123abcd" } }
public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddSingleton<IConfiguration>(Configuration); services.Configure<AppSettings>(Configuration.GetSection("AppSettings")); }
public class security { private AppSettings AppSettings { get; set; } public security(IOptions<AppSettings> settings) { AppSettings = settings.Value; } public static bool Login(string username, string password) { if (username == AppSettings.User && password == AppSettings.Password) { return true; } else { return false; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)