简体   繁体   中英

Redefine application settings in web.config

There is an ASP.NET application. It is referenced to a .NET project which has web reference to an asmx web service (for example this project is MyApp.Utility).

The URL to web service is stored in the application settings. There is such section in app.config for MyApp.Utility project.

<applicationSettings>
    <MyApp.Utility.My.MySettings>
        <setting name="MyApp_Utility_ExternalServices_SomeService" serializeAs="String">
            <value>http://localhost:17455/ExternalServices/SomeService.asmx</value>
        </setting>
    </MyApp.Utility.My.MySettings>
</applicationSettings>

I want to change this URL in web.config for my ASP.NET application. Can I redefine application settings of MyApp.Utility without recompiling the code?

yes, you have stuff in .config files exactly so that you don't have to recompile to change stuff.

Depending on what kind of app and setup you have you might have to restart the application in order for it to read in the new values, but no recompile is necessary.

however: if the .config file is for a non-website project (web.config) it will be called app.config and be placed in the project root. This is not the file being read runtime, the file actually being used is called ProjectName .dll.config and will be in the /bin folder next to the ProjectName .dll, when you compile the code msbuild copies and renames the app.config file into this location.

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