I am developing a Silverlight 4 application and I want to enable/disable some features when deploying the app locally for testing purposes.
For example, metrics collecting will be disabled when I test the application locally to avoid spamming my database of “live” metrics.
The way that I am currently doing this is by checking the host name. For example, in my App.xaml.cs file:
if (HtmlPage.Document.DocumentUri.Host == "localhost")
{
// Do stuff only when deployed locally
}
Is there a better way to do this?
I create two html pages to test my code, for example mysilverlightpage.html and myslpage.notracking.html. Then in the object embed tag for myslpage.notracking.html I add an initparam:
Then in my code, I do a check on my InitParams params:
Now it’s possible to check the release version for functionality without invalidating your tracking metrics.