var name = app.ApplicationServices.GetService<ISiteDefinitionRepository>().List().First().Name;
this probably works - untested by me
It should be IApplicationBuilder
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//other code
var name = app.ApplicationServices.GetService<ISiteDefinitionRepository>().List().First().Name;
}
I think the correct code would be:
var name = app.ApplicationServices.GetInstance<ISiteDefinitionRepository>().List().First().Name;
Note that this will obviously just give you the first website, which is necessarily not what you want. You will need an http context to be able to resolve a website that is actually matching the current request, and this can not be done during configuration.
Just to echo Johan here, startup.cs is the configuration of the site, not the routing and delivery of a site's content.
What problem are you trying to solve by getting a site name during the startup.cs?
Hey Kumar, Could you please explain why you want the Sitename in startup.cs file?
How can we get the site name from the manage website (admin tab) by using the startup.cs file