I`m starting a small open source project in .Net Core 2.0, to learn about this thechnology. I have a empty project and I need to read in the beginig from a remote URL feed. I need thath, the URL be able to be modified, and I thing thah the best way is writing it in the appsettings.json file of the project. But I don´t know how to read this file from the Startup.cs class.
I have tried this, but does not work in .Net Core projects
ConfigurationManager.AppSettings["DataURL"];
This is the content of the Startup.cs class:
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
using (WebClient wc = new WebClient())
{
string jsonData = wc.DownloadString("http://servizos.meteogalicia.gal/rss/observacion/ultimos10minPlataformas.action");
JObject jsonObject = JObject.Parse(jsonData);
}
});
}
}