How do I merge web services' app.config with web app's web.config? Help!!

I have a web application project that uses a separate class library containing web service references (service layer). I want to be able to configure the web reference URLs dynamically and I know you can set this up by setting the URL behavior to  'Dynamic', etc, etc. The problem is VS2005 puts the URLs in the project's app.config file. When the class library becomes a DLL component, I have no way of accessing the app.config file.

Is there a way to make the web reference project to look for the URLs in the web.config instead of its app.config? Or is there a way to merge this app.config with web.config?

Any help is greatly appreciated. Thanks!!


4/20/2007 7:58:11 PM 12495 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 42

4/20/2007 9:09:19 PM

Just an FYI... I followed the steps in that link and could not get my web service URL's in the web.config to be used.  For those who have a web application that uses a Class Library project which contains a web service and want to move the Class Library project's app.config settings to your web.config, here are the steps I used to accomplish this:

1. Added my web service url in the <appSettings> section in my web.config

    <add key="MyWebServiceURL" value="http://my_webservice_url.asmx"/>

 2. Changed my Class Library project to "Show All Files"

3. Navigated to my "Web References --> my_web_service --> --> Reference.cs" file

4. Changed "this.URL" to point to the web.config appSettings entry

this.Url = System.Configuration.ConfigurationManager.AppSettings["MyWebServiceURL"];

Now, I can change this web service url after deployment without any recompiling.

Hope this helps someone.

4/8/2008 1:21:21 PM

Similar Artilces:

Isolating web.config from it's parent web.config
I need to run an application withing a sub-directory of another application. Basically, I need to install an old version of DNN as a subdirectory of a current DNN2 installation. I get a problem of conflicting web.configs. The subdirectory want to use it's parent directory's web.config file. I thought by making the subdirectory an "application" in IIS that it would use the web.config in it's own folder but instead, it is referenceing the web.config file from it's parent. Any thoughts or help would be appreciated. Thanks, Stef. Stef, Because of the hierarchical nat...

Need to put this in a web.config file. Transfer a collection from app.config to web.config.
<!--<setting name="Groups" serializeAs="Xml"> <value> <ArrayOfString xmlns:xsi="" xmlns:xsd=""> <string>GL CA Corporate Data</string> <string>GL CONT Contractors</string> <string>GL IT SolutionDelivery</string> </ArrayOfString> </value> </setting>-->   I need to put this in the below web.config.<?xml version="1.0"?><!-- Note: As an alternative to hand editing this fi...

how to let the web.config in the sub-directory to NOT to inherited from Root's web.config.
Hi,all,   How to let the sub-directory to avoid the authentication control from Root's webconfig? I heard that we can add a new web.config to the sub-directory. And then we can slove the problem.   Virtual directory is :http://localhost/main   Sub-directory is : http://localhost/main/reminder   My application used the Forms Authentication, then all files in every directory is controlled by the Forms Authentication. But now i want a sub-directory to avoid this. (user can access this directory directly, Needn't to Login.)   In my application, the user can ac...

Merging my web.config.mylibrary with the web.config
I see multiples web.config files in the framework 2.0 folder.  There is a way to had a web.config.mylibrary file that contains part of the configuration section.For example, I want that the profile section to be in the web.config.mylibrary file and when the web site will be load, the two web.config will be merge.  Is it possible to such thing ? Hi Biz, It is possible to-do this using the configSource property on configuration section elements.  You could then store different configuration sections in different configuration files in a distributed way.Here is a MSD...

running 2 web.configs in the same website 1 in /web.config and one in /swf/web.config
Im having issues doing this. and when i remove the authentication from the swf/web.config it still doesnt seem to be applying to the child website at all. Whats the proper way to set a child website? Thanks!!  The lower most web.config overrides all previous settings. So if you remove the section from the /swf/web.config whatever settings you have in the web.config in the next higher level will have an effect on the content of the child folder.So instead of removing a section, try giving appropriate settings in the /swf/web.config....

Help!!! App.config Vs Web.config
Hi All My web application has a class library and it uses both App.Config and Web.config files. It also has a Settings.setting file. App.Config  is automatically generated when I add the WebService references to this project. It also has a sql connection string which uses by TableAdapters. My question is can I remove the App.Config file and just maintain only the Web.config file? Would it stop functioning the SQL connection or Web Service? Is there a way I can move all my app.config items to Web.config so the application can only use the Web.config file? Would the TableAdpaters ...

app.config and web.config deployments and installers
I use web deployment projects for changing web.config values based on the configuration build types I have setup (dev/test/stage/prod) and it works excellent for building installers in multiple environments.  Now, I am trying to do the same the Windows Applications.  How can I automate the changing of app.config values based on the build configuration (dev/test/stage/prod)?  Any help would be much appreciated. Thanks,Chris...

Hello!! I'm development a web application in n-tiers. The UI have a web.config, and the other tiers using app.config. The problem is that the application doesn´t recognize the app.config files. Only the web.config of the UI. For example: I try to put the connections string in a app.config in the data access, but when it runing, throws a error that says: "Database undefined". But when I put the connections strings in the web.config, it runing well. I need help!!!Alvaro HdezDeveloper To use xml atributes from WebConfig and AppConfig u must add referance to System...

I have setup custom config sections. I need to know how to loop through a configuration group and get all of the config sections in that group. Thanks could you post an example of what you have Trey Exactly, your question is not clear at all. Regards.Bilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP...

App.config to Web.config
I have been running a console app, to process a paypal payment.  The code gets a value from the app.config file. <add key="PAYFLOW_HOST" value="" /> However I have now incorporate the code into a web application and put the key into my web.config file, will the code now know to look for this key in this place? If your code is getting the value from your config file using ConfigurationManager.AppSettings["PAYFLOW_HOST"] then it should use the correct config file automatically.  Console apps, windows services and wind...

Read info from web.config, machine.config, app.config....
I know how to read info from the web.config, see code:  Protected path As String = "/Framework" Protected config As Configuration = WebConfigurationManager.OpenWebConfiguration(path) How can I read also the data from machine.config and other config files, like the app.configs?Johan TheunissenMCPD, MCSE, MCTS BizTalk 2006==============================Please mark the most helpful reply/replies as "Answer". ...

Deploying Web App > web.config hell ?
Hello, for the last 8 hours or so I'm trying to deploy one of my personal apps on a hosted server. I've asked the host to set the folder both as a virtual directory and as a web application. Both is done and confirmed. Now I've uploaded the application (compiled using the Project Copy in VS.NET) including the bin folder. Whenever I access the app I get this error: The web.config file looks like this (standard): <?xml version="1.0" encoding="utf-8" ?> <configuration> <system....

membership not added to app's web.config
I am using Visual Web Developer 2008 and Sql Server 2005 Express. When I use the web config tool to setup membership and roles no code is added at all to my app's web.config, shouldn't it have generated code similar to what's below? (copied from Guthrie's blog) <membership>             <providers>                 <clear/>                 <add name=&quo...

Using multiple web.configs with different web apps in the same web folder.
How do I tell a web application to use a specific web.config file instead of referencing the root web apps web.config file? Example: In IIS i have this setup:My Server  Web Sites     Default Web Site (this has web.config with a reference to a HTTP Handler)     My Http Handler           My Sub Web             < --- This sub web is looking for the http handler in this web hope that makes sense.   shawn use location elem...

Web resources about - How do I merge web services' app.config with web app's web.config? Help!! -

Resources last updated: 2/5/2016 1:37:43 PM