Sunday, January 18, 2009

Encrypting and Decrypting connection strings in web.config

In an ASP.NET website or web application, connection string for connection to a database server are stored in web.config file. It becomes easy to manage and access the connection strings from a central file accessible to all ASP.NET pages. But the security and privacy of the connection strings are higly important. It is a good idea to protect the connection strings in web.config by encrypting them. ASP.NET gives a built in way to do this. We can use RSAProtectedConfigurationProvider to encrypt the connection strings using User Level Key and Machine Level Key. User Level Key is used when you are running your application on a shared server and Machine Level Key is used when you are running your application on dedicated server. In this article we will see how to encrypt using Machine Level Key. In the web.config following is the section having all connection string:

After storing all connection strings, go to the Visual Studio 2005 Command Prompt.
(Start->Programs->Microsoft Visual Studio 2005->Visual Studio 2005 Tools->Command Prompt)

There write this command on command prompt:

aspnet_regiis -pef "connectionStrings" "c:\myProjects\website1"

Where the "c:\myProjects\website1" is the physical path of your website. Review the web.config after this. You will find it encrypted.

Later on you can access this connection string as normal way in your pages:



To revert the web.config connection strings back to plain text:

aspnet_regiis -pdf "connectionStrings" "c:\myProjects\website1"

Microsoft Silverlight 2

From Microsoft website available to public

Microsoft Silverlight 2

Fact Sheet

October 2008

A New Way to See the Web

Over the past year Microsoft Silverlight has led the way for developers and designers to create compelling media experiences and rich Internet applications (RIAs) on the Web via an easy-to-use, quickly installed browser plug-in. With the release of Silverlight 2, Microsoft Corp. is delivering a wide range of new platform features and tooling options that enable designers and developers to better collaborate while creating more accessible, more discoverable and more secure end-user experiences.

Silverlight Momentum

Silverlight is one of the fastest-growing browser plug-ins in history, both in terms of customer adoption and consumer installations. In 2008, Silverlight powered the 2008 Beijing Olympic Games ( and the Democratic National Convention ( In addition, companies such as CBS College Sports Network, Blockbuster Inc., AOL LLC, Hard Rock Cafe International Inc., HSN Inc. and Toyota Motor Corp. are using Silverlight to provide a unique and dynamic Web experience for their customers. Silverlight has also been widely adopted throughout the developer and designer community by means of the Silverlight Partner Initiative. With more than 150 companies in the program — 120 of which have joined in the past year — it is a vibrant ecosystem of agency, solution provider, content delivery network, independent software vendor and independent hardware vendor partners, which are delivering some of the most innovative Silverlight experiences on the Web today. Finally, consumer installations of the Silverlight plug-in are growing rapidly, with penetration in some countries approaching 50 percent.

Openness and Interoperability Support

Proving its commitment to openness and its support for interoperability, Microsoft is funding a project to integrate advanced Silverlight development capabilities into the open-source Eclipse integrated development environment (IDE), will publish the Silverlight Extensible Application Markup Language (XAML) Vocabulary Specification, and will make the Silverlight Control Pack available as open source software.

“We have been very pleased to have a project proposed to create Eclipse tools for Microsoft Silverlight,” said Mike Milinkovich, executive director of the Eclipse Foundation. “This proposed project will provide Eclipse developers with the ability to leverage Silverlight and Java Web Services when developing rich Internet applications. Having a strong endorsement from Microsoft for this project is a clear sign of their support for Eclipse and open source communities.”

· The Eclipse Tools for Microsoft Silverlight Project will integrate advanced Silverlight development capabilities into the Eclipse IDE and Eclipse Rich Client Platform. Developed by France-based IT solution provider Soyatec, the project is funded by Microsoft.

­ Increased interoperability. Eclipse will contain functionality that will help Java developers build Silverlight applications that work better with Java Web Services using representational state transfer (REST), Simple Object Access Protocol (SOAP), JavaScript Object Notation (JSON) and other standards.

­ Silverlight Project System and Silverlight Compiler. Eclipse will contain both an advanced project system for creating Silverlight applications and media experiences and a compiler for packaging Silverlight applications for deployment.

­ XAML editor and preview with code hinting and code completion. Eclipse will contain an advanced, standards-compliant XAML editor with code hinting and code completion, which helps detect and correct coding errors.

­ Full compatibility with Microsoft’s development and design tools. The XAML and Silverlight projects created by Eclipse will be fully supported by both Microsoft Visual Studio and Microsoft Expression Studio tools.

­ Results. See the picture below for a glimpse of a Silverlight application being created in Eclipse.

­ Availability. A preview of the bits was posted today at under the Eclipse Public License Version 1.0. Customers can use the SourceForge project site to submit bugs and feedback or contribute to the project. The release candidate is scheduled to be available free for download by spring 2009.

­ Road map. Although the first version of the Eclipse Tools for Microsoft Silverlight will be optimized for the Windows version of Eclipse, the project plans to offer full support for the Mac and Linux versions of Eclipse in a later release.

· By publishing the Silverlight XAML Vocabulary Specification under the Open Specification Promise, Microsoft will better enable ISVs to read and write XAML for use in Silverlight projects in other design and development software applications, thus accelerating the creation of a robust authoring and server ecosystem for Silverlight. This documentation release complements Microsoft’s existing published specifications of the XAML object mapping rules and XAML vocabulary for Windows Presentation Foundation (WPF).

· By making the Silverlight Control Pack available as open-source software, which is built on CodePlex and released under the Open Source Initiative-approved Microsoft Public License (MS-PL), Microsoft is helping developers easily customize and ship their own expanded controls, augmenting the powerful built-in control set that already ships in Silverlight.

­ Featured controls in the Control Pack. DockPanel, WrapPanel, ViewBox, Label, HeaderedContentControl, Expander, TreeView, NumericUpDown, AutoComplete and Accordion are available.

­ Advanced skinning support. The Silverlight Control Pack will provide additional control skins and templates to customize the look and feel of both the core Silverlight and Control Pack controls.

­ Learning opportunity. Developers can learn how to create their own advanced Silverlight controls by using high-quality Microsoft source code as a starting point.

· Growing tooling support from partner ecosystem. Tool support for building Silverlight-enabled applications continues to grow, with partners such as Captaris Inc., Telerik Inc., ComponentOne LLC, Infragistics, Software FX Inc., Intersoft Solutions Corp., Developer Express Inc., K2, Gizmox and RemObjects Software LLC providing products ranging from forms layout and rich interactive components to workflow, programming languages and business intelligence.

“Microsoft is thrilled to see the momentum building around tooling support from our partners,” said Scott Guthrie, corporate vice president of the .NET Developer Division at Microsoft. “The breadth of these partner offerings enables Silverlight developers to build evermore sophisticated and capable applications, further broadening the appeal of Silverlight for use in a wide range of scenarios.”

New Features in Silverlight 2

Highlights of new features of Silverlight — which are fully supported by Expression Blend 2 SP1 and Microsoft Visual Studio 2008 SP1 — include these:

· Expanded .NET Framework language support. Unlike other runtimes, Silverlight 2 supports a variety of programming languages, including Visual Basic, C#, Managed JavaScript, IronPython and IronRuby, making it easier for developers already familiar with one of these languages to repurpose their existing skills.

­ Cutting-edge RIA development. With Silverlight 2, developers do not have to pay the “productivity tax” of converting their existing code to JavaScript to run inside the client. With support for languages such as Ruby and Python, Silverlight 2 enables developers to be on the cutting edge of RIA development, creating Asynchronous Ruby and XML (ARAX) and Asynchronous Python and XML (APAX) applications.

· A rich base class library. A compatible subset of the full .NET Framework gives developers the most comprehensive RIA runtime on the Web today, with unparalleled data access capabilities, local data caching and local data storage, superior input-output (IO) performance, and better threading. By leveraging the rich base class library of the .NET Framework, developers can minimize the amount of additional code they have to write for their projects.

­ Building better AJAX applications. Silverlight 2 includes APIs that enable the creation of better asynchronous JavaScript and XML (AJAX) applications, with improved HTML DOM/JavaScript integration with .NET code and with better data access through Language-Integrated Query (LINQ) and LINQ to XML library support.

· Powerful built-in rich controls allow developers and designers to quickly build applications through a rich set of built-in controls such as DataGrid, ListBox, Slider, ScrollViewer and Calendar. With the rich controls built into Silverlight 2, developers don’t have to start from scratch when building the controls for their rich Internet applications.

· Advanced styling and templating support gives designers and developers complete control over the look and feel of an application to ensure the custom brand experience for their rich Internet application meets their exacting requirements.

· Rich UI Library. Silverlight 2’s UI Library, a compatible subset of the WPF user interface framework featured in the full .NET Framework, makes building rich Web applications easier. The powerful graphics and animation engine enables developers to reuse skills, code and content to build rich applications for the browser that can be rapidly ported to the desktop and devices.

­ Better support for higher-level UI capabilities. The UI Framework in Silverlight contains support for higher-level UI capabilities such as layout management, data-binding, styles and template skinning.

· Comprehensive networking support enables Silverlight users to leverage the power of the .NET Framework’s Windows Communication Foundation and directly access resources on the Web by supporting cross-domain network access.

­ Out-of-the-box support for calling REST, WS*/SOAP, POX, RSS and standard HTTP services enables users to create Web 2.0-style applications that easily integrate with existing heterogeneous back-end systems.

· Advanced content protection features, now including Silverlight digital rights management (DRM), Powered by PlayReady. Silverlight DRM builds on Microsoft’s extensive expertise in developing DRM technologies, delivering robust protection for key Silverlight scenarios including live streaming, on-demand streaming and progressive downloads for connected experiences.

· Improved server scalability and expanded advertiser support. The combination of Silverlight 2 and Windows Server 2008 offers streaming video professionals industry-leading scalability and cutting-edge progressive download features. In addition, Silverlight offers superior search engine optimization capabilities and advanced in-stream advertising support through companies such as DoubleClick Inc. and EyeWonder Inc.

· Unparalleled interactivity with high-resolution content through Deep Zoom technology. The new Deep Zoom technology in Silverlight allows users to see images on the Web as never before. The smooth, in-place zooming and panning that Deep Zoom allows is a true advancement and raises the bar on what image viewing should be. It is also now possible through this feature to make super-high-resolution images easily consumable on the Web. Even better, Deep Zoom is designed in a way that will reduce Web hosting and bandwidth costs by sending to the browser exactly the right size and resolution image for the current display area.

Truncate and Delete

Delete table is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow.

Truncate table also deletes all the rows in a table, but it won't log the deletion of each row, instead it logs the de-allocation of the data pages of the table, which makes it faster. Of course, truncate table cannot be rolled back.

Truncate table is functionally identical to delete statement with no where clause both remove all rows in the table. But truncate table is faster and uses fewer system and transaction log resources than delete.

Truncate table removes all rows from a table, but the table structure and its columns, constraints, indexes etc. remains as it is.

In truncate table the counter used by an identity column for new rows is reset to the seed for the column.

If you want to retain the identity counter, use delete statement instead.

If you want to remove table definition and its data, use the drop table statement.

You cannot use truncate table on a table referenced by a foreign key constraint; instead, use delete statement without a where clause. Because truncate table is not logged, it cannot activate a trigger.