views:

59

answers:

1

I need to change database and settings when my customers load the application (xap) on different URLs.

Examples:

  • client A connects on URL: www.clienteA.com/system
  • client B connects on URL: www.clienteB.com/system

The two urls above call the same xap file, but I need to change database and settings; how I do that?

A: 

Do those URLs actually resolve to the same site/server? IMO, the easiest way to do this is to do it as part of your build process. When you publish the app for "client A", you use the web.config (etc) for that client - and ditto "client B". May SCM systems allow this type of per-client configuration, or it is pretty easy to do it with a few build scripts.

The alternative (if they absolutely must be the same physical code files on the same server) is to move this into the machine's web.config - much more complicated, but you can use the "location" node in web.config to specify connection-strings per IIS site, even if they resolve to the same files. I stress that this is risky, hard to verify, and easy to get wrong - the build process is my preferred option!

Marc Gravell
Thanks, Marc!!My priority is fast > simplicity deployment of new costumers!!Compilation is dangerous (I think) and Slow, imagine this senary:1 - 1000 Costumers.2 - I found a bug in my code.3 - I have to compile 1000 xap changing coniguration for each one.Im thinking some one like this:1 - url = DiscoveryURL();2 - Service.GetConfiguration(url); // Get DataBase Coonections and More3 - Now the process is the same for each costumer.My question is how i do the DiscoveryURL() method??
CrazyJoe
Do you mean Application.Current.Host.Source.AbsoluteUri?
Marc Gravell
(or Application.Current.Host.Source.Host if you just want the server)
Marc Gravell
this will work fine, thank man!!
CrazyJoe