2

I'm sure this is a common requirement. I have written an ASP.NET app but now I have testing requirements. Basically the application uses webservices and as such currently these are in the code. I need to be able to run the same aplpication using test URL's in as simple way as possible.

I was thinking I could put the URL's in the web.config and comment/uncomment the the variable as required.

I was thinking however how is this done in windows apps. I know that some applications, you specify on the command line when launching the env (e.g. prod, uat, prl) and the application then uses the relevant URL's - I presume this isnt done with if/else statements everywhere?

if(UAT){URL=app.settings["UATURL"]}

Any information on how this is done in a professional application for testing is appreciated.

1
  • Wrap a settings manager around all your configuration calls - let this do the checking of what environment you are in. No need to have if statements all over the place, put it into one manager class. Commented Aug 31, 2012 at 21:53

2 Answers 2

1

You can create build configuration and use Web.Config transformation for the different environments as descripted here

If you have your build configurations you can also use the C# Preprocessor Directives #if like for example this:

#if DEBUG Console.WriteLine("Debug version"); #endif 
Sign up to request clarification or add additional context in comments.

Comments

0

Add this code to your head tag:

<head> <base href="http://www.yourwebsite.com/optionalInnerPath/" target="_blank" /> </head> 

Specify your site path in the href attribute and all the paths in your site will be relative to this path.

1 Comment

He's referring to webservices, this is only handy for client-side things like images and links.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.