开发者

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 开发者_StackOverflow社区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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜