Last post Jun 19, 2019 06:02 AM by Yuki Tao
Jun 18, 2019 02:52 PM|slimbunny|LINK
I need to determine if the website is running on TestServer or Devloper's Server. I am using appSettings to get set the file path,
What code do I use to determine which server I am on? How do I detect the server?
Jun 18, 2019 02:56 PM|PatriceSc|LINK
The file path of what ? It could be maybe the same on distinct servers ? I would use a single System.Configuration.ConfigurationManager.AppSettings["EnvironmentName"]
value which would be "Production" or "Development". From now when doing something and even when not using ASP.NET Core you may want to have a look at how it is done in this version: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-2.2 and
do something similar.
Else it seems your intent would be to compare Server.MapPath("~/") to both AppSettings["TESTServerPäth"] and AppSettings["DevServerPath"] ???
Jun 19, 2019 06:02 AM|Yuki Tao|LINK
I need to determine if the website is running on TestServer or Devloper's Server.
If you want to determine TestServer or Devloper's Server,
You could try to use HostingEnvironment.IsDevelopmentEnvironment
Property to check TestServer or Devloper's Server.
Its explanation is: ‘Gets a value that indicates whether the current application is in a development environment.’
For example: you could check the value of HostingEnvironment.IsDevelopmentEnvironment in BaseController and handle based on your need.