We have more or less the following infrastructure 1. In production we have WFE, App Serv, UAG. We have some configuration to point internet URLs to sites on THE dmz production farm. Something like www.mydomain.com will go to http://server1 or whatever.

  1. In testing environment we have the same config,

  2. However in dev environment we dont have an UAG servers but we do have alternate access mappings. So, one site like http://devenvironment.ourdomain.com actually goes to http://devserver The dns admin created dns records to be able to see that URL from the workstation or from the development server itself, which by the way has visual studio installed.

In sharepoint, many times you need to interact with SPWeb and SPSite objects, and in the constructor sometimes you have to use the URL, so:

  1. I suppose the AAM Url wont work?
  2. Should I use always the real internal url aka Server name?
  3. What approach would you recommend to develop in this environment specially when I will heavely use Spweb and Spsite objects?
  • This is just to be sure, that when we move from dev to test and test to prod everything works Feb 23, 2012 at 9:12

1 Answer 1


You should not hardcode a URL into your code. In most cases you can access the context your component is in and can therefore access the objects without a specific hardcoded URL. If you are writing a program that runs outside of SharePoint, and therefore the context must be provided, you should add a configuration section/file of some sort to allow you to change this on the fly.

Without knowing more details of what you are actually coding (web part, feature, workflow action, etc.) I can't be any more specific than that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.