Problems with web.config and app.config

I have a DLL that references a web service.

The block that he placed in app.config (I changed the names, but you get the idea):

<applicationSettings>
    <DLLName.My.MySettings>
        <setting name="DLLName_WebReferenceName_ASMXName"
            serializeAs="String">
            <value>http://URL/Filename.asmx</value>
        </setting>
    </DLLName.My.MySettings>
</applicationSettings>

My site is linking to this dll.

The question is, what can I add to web.config to override the above parameter (alternatively, just put app.config in the BIN directory)?

I need to redefine the web service url on the production server because it cannot reach the url specified in app.config (this is another problem that we will not enter).

+3
source share
2 answers

Group configSections, applicationSettings, app.config web.config, , app.config.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" 
                type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="Playground.ConfigurationOverride.DataAccess.Properties.Settings" 
                    type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
                    requirePermission="false" />
        </sectionGroup>
    </configSections>
    <applicationSettings>
        <Playground.ConfigurationOverride.DataAccess.Properties.Settings>
            <setting name="MySetting" serializeAs="String">
                <value>Setting in DataAccess</value>
            </setting>
        </Playground.ConfigurationOverride.DataAccess.Properties.Settings>
    </applicationSettings>
</configuration>
+6

Asp.Net:

Web.config:

Web.config , IIS. Web.config IIS, , - Kestrel. web.config, IIS.

AppSetting.json:

, IIS, AppSetting.json. AppSetting.json Asp.Net Core. ASP.NET Core "ASPNETCORE_ENVIRONMENT" . , , "AppSetting.production.json". Visual Studio , "AppSetting.json". . -, , Windows.

App.config:

App.config - , .NET, Windows Forms, Windows Services, Console Apps WPF. Asp.Net Core , app.config.


;

, . IIS , Web.config. - , App.config. . " ", " ASP.NET".

0

Source: https://habr.com/ru/post/1718997/


All Articles