简体   繁体   中英

Is there a way to dynamically choose web.config in Angular?

I have three similar sites with little differences that are published from the same Angular project. Currently, there are three web.config files that are manually chosen for the relevant site when publishing.

I want to know if there is any technique that the process of selecting the web.config file can be dynamic when publishing. Or, maybe having different sections inside one web.config file and choose the section according to the site. Is there any way to achieve this?

The approach that I have used is to create an endpoint (ApiController) that will return the values on your web.config using the Configuration class (I will asume that we you are doing MVC or AspNetCore) and creating a model that match with web.config data. Then you will create an Angular Service that will request this endpoint as soon as your app loads, and my personal approach I always inject this data in the routes because it should not change.

Happy coding and stay safe!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM