var values = new NameValueCollection
{
{ "key", ConfigurationSettings.AppSettings["API-Key"].ToString() },
{ "image", Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) }
};
What's the new way to use the app.config file?
ConfigurationManager was added to support ASP.NET Core's new WebApplication model, used for simplifying the ASP.NET Core startup code.
GetSection(String) Method (System. Configuration) Retrieves a specified configuration section for the current application's default configuration.
The ConfigurationManager
class in System.Configuration
:
ConfigurationManager.AppSettings
ConfigurationManager.ConnectionStrings
So your code would change to:
var values = new NameValueCollection
{
{ "key", ConfigurationManager.AppSettings["API-Key"] },
{ "image", Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) }
};
Make sure you add a reference to System.Configuration
along with the using
statement for System.Configuration
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With