I'm trying to configure an ASP.NET Core (2.1) application in the same IIS server with two different url/port, each url/port should use different DataBase connection e.g.:
- http://localhost:55001 (use QA DB connection)
- http://localhost:55002 (use Production DB connection)
This scenario is for using an intranet web application. A group of users will use the Production app. Another group of users will use the QA or Staging app. This two urls/db-connections must be enable in the same application at same time in order to have one main app (for policies, maintaining and machine resources consumption purposes) and two different databases.
What I've tried is to configure two appsettings.json files: the first (appsettings.Release.json) sets the production database connection string and a applicationUrl url/port. The second one (appsettings.QA.json) defines a different database connection string and different applicationUrl.
appsettings.Release.json:
{
"ConnectionStrings": {
"default": {
"ConnectionString": "<production-connection-string>",
"ProviderName": "Oracle.ManagedDataAccess.Client"
}
},
"applicationUrl": "https://localhost:55001",
...
}
appsettings.QA.json:
{
"ConnectionStrings": {
"default": {
"ConnectionString": "<qa-connection-string>",
"ProviderName": "Oracle.ManagedDataAccess.Client"
}
},
"applicationUrl": "https://localhost:55002",
...
}
Now here I'm a little bit lost, the next configuration settings I need to achieve are confusing and not clear for me. I don't even know if what I'm trying to achieve is possible or acceptable. If I define an ASPNETCORE_ENVIRONMENT variable value for each appsettings[environment/scenario].json then I cannot use two values for this variable at the same time right?.
So I'm thinking that set and use the ASPNETCORE_ENVIRONMENT may not be the answear to my problem. Also I have to properly configure the startup and (maybe) program classes to achieve what I'm looking for.
So well at this point, any advice, guidance, code snippet or solution you guys may have will be very appreciated.