Friday, 3 February 2012

Managing Web.Config for different environments

Why do we have different environments? And why do different environments need different configurations? This question need not be answered if you see what those different environments are:
Production/Live, UAT/Staging/Operations/Like-Live, Quality Assurance and  Development. One cannot have the same SQL Server in production and Development environment.

Now, about the problem in context. Different teams have different approach to manage web.config entries in different environments. Some edit the file manually after deployment, some edit configurations as part of the installation using some custom actions, some have design approach to have config values stored away from web.config with only the identifiers available in the config file.

In any scenario, all teams have all details of different environments upfront. Given that, would it not be a nice thing to have a one time activity that will ensure configuration changes are automatically applied to different environments as part of deployment? . VS2010 provides you exactly that.

Read about Web.Config Transformation here: http://msdn.microsoft.com/en-us/gg454290

An example:
If you have a connection string in your web.config as follows
<?xml version="1.0"?><configuration><connectionStrings><add name="MyConnStr" connectionString="Data Source=DevIP;Initial Catalog=SampleDB;User ID=sa;Password=sample;" providerName="System.Data.SqlClient" /></connectionStrings>

You can transform the connection string to production settings by adding a web.production.config with content as
<?xml version="1.0"?><configuration  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"><connectionStrings><add name="MyConnStr" connectionString="Data Source=ProductionIP;Initial Catalog=SampleDB;Integrated Security=True" providerName="System.Data.SqlClient" xdt:Transform="Replace" xdt:Locator="Match(name)"/></connectionStrings>

Replace Transform means the entire node will be replaced in the web.config with entries specified here. Web has information aplenty on this; explore and enjoy learning.

PS: "Do google to learn more" sounds fine, why not "Do bing to learn more"??

Thursday, 19 January 2012

Will Silverlight live long?

We have started to work on a product that involves too much of Silverlight. Yes, finally we come to work on something where Silverlight fits very well. Very rich user interface for a facility management software with a defined list of users. Team got too excited and started a lot of reading and doing. Then comes the heartbreak that our product might soon be redone with HTML5 instead of Silverlight. 

Reason, the same story, Microsoft’s strategy with Silverlight has shifted. Though the support pages say Silverlight will remain at least until 2021, reading between lines convey IE9 may be the last official browser to support Silverlight.

One never really knows if Silverlight will be discontinued; however the big heads’ “Change in strategy” statement on a Professional Developer’s Conference will surely drive everyone away; we are no exceptions.

Frustration is when the playmaker is silent and players wonder if what they do is really a waste of time. Guess it is better for us, players, to play in daylight than under floodlights.

References:
http://www.zdnet.com/blog/microsoft/microsoft-our-strategy-with-silverlight-has-shifted/7834
http://support.microsoft.com/gp/lifean45
http://www.dailytech.com/Microsoft+Considers+Silverlight+Exit+Strategy+Platform+May+Get+the+Axe/article23240.htm
http://www.dailytech.com/Microsoft+Teams+Up+With+Apple+Dissing+Adobe+and+Praising+HTML5/article18276.htm
http://www.silverlighthack.com/post/2010/10/29/PDC-2010-Top-5-Reasons-Why-Microsoft-Completely-Screwed-up-their-web-strategy-with-HTML-5.aspx


Throw some light!