Web Config use

Balu Raju 76 Reputation points
2022-06-21T20:37:31.4+00:00

I have a typical requirement. We have several WCF services using NetHttpBinding. We are developing a new Core Web API for a new project.
We plan to use the existing WCF DLLs in new web API that. one of the DLLs is data layer that uses connection string form Web.config file.
The new Core Web API uses these existing DLLs. However, We cannot change the existing WCF services nor can we change the DLLs to use appsettings.json file because WCF Services are still used by legacy application.

First I thought I would just define the connection strings in web API appsettings.json. It did not work.
Next, I added a web config file to the new Core Web API and defined the connection strings there, it did not work.

I cannot call WCF service from Web API because it uses custom binding such as NetHTTPBinding that I may have define in Web API.

I could use WCF Dlls from any other application such as console application using the web config. I thought I could use same concept with Web API by referncing the DLLs directly, but the DLLs is reading neither the appsettings.json nor the web config file.

Any insight will be appreciated.

Here is the scenario
Current WCF Service S1 uses DLL D1. D1 uses web config to read the web config. this works as part of WCF services. No problem here.
Created a new Core Web API that uses its own appsettings.json. for its own connection string.
the new Core Web API uses the existing DLL D1. However, D1 does not read connection string from AppSeetings.json.
Then I added a Web Config file to the Core Web API. Still the DLL D1 does not read the connection string from Web.Config.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,264 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,077 questions
{count} votes