views:

31

answers:

3

I did a couple google searches about this and am not finding anything, so I thought I'd ask here.

I'm working on our internal CMS and I noticed that we're getting live data back when doing debugging because of our web services instead of the dev data that I wanted. It doesn't do this on our dev CMS website, but we're trying to do all our development on localhost. Is there any way to set up an environment variable in our web config for the URL so that the CMS points to the dev database instead of live database that is referenced in the wsdl files?

+1  A: 

You can use the appSettings portion of the web config to for configuration information.

In the configuration section of the Web.config you will find the appSettings section:

  <appSettings>
    <add key="Key" value="Some Value"/>
  </appSettings>

In code you can read in the value like this:

var someValue = ConfigurationManager.AppSettings["Key"];
Dan
A: 

+1 for Dan's method of storing the URL. To use this URL at runtime just update the URL property of your web service proxy object with the value from your web.config.

MyClientClass o = new MyClientClass();
o.Url = varFromWebConfig;
o.MyWebMethod();
BenV
A: 

Actually, one of my coworkers suggested an alternate way of solving this issue which seems even better to me: fixing it server-side, rather than client side like I've been trying and has been suggested here. His suggestion was to create a subdomain in IIS on all of our servers that points to the web service folder and then put host files for the appropriate web server on my local machine. This seems like the ideal solution to me since it wouldn't require changing all the current web service proxy objects like the client side solution would, just the web service consumption within App_WebReferences.

Evan