Tuesday, November 12, 2013

How To Encript and Decript Web.Config CONNECTION STRING

Step to Encript Connection string :

Step 1: Open CMD As Administrator

step 2:  cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

step 3: aspnet_regiis -pc "MyKeys" -exp

 Step 4:
**** For Local Machine ******
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pa "MyKeys" "Max70-PC\Max72"

**** For Server Machine ******
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pa "MyKeys" "NT AUTHORITY\NETWORK SERVICE"

Step 5 : Add This section to your Web.Config File in "configuration" Section

  <configProtectedData>
    <providers>
      <add name="MyProvider"  type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
           description="Uses RsaCryptoServiceProvider to encrypt and decrypt"
           keyContainerName="MyKeys"
           useMachineContainer="true"
           />
    </providers>

  </configProtectedData>



**** -each site must have a identity in IIS. take that ID. i.e -Site "4" . ***

Step 6:  C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pe "connectionStrings" -site "4"  -app "/" -prov "RsaProtectedConfigurationProvider"



Step to decript Connection string :
Step 1: Open CMD As Administrator

Step 2:  cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

Step 3:   aspnet_regiis -pd "connectionStrings" -site "4"  -app "/"

Ref : http://msdn.microsoft.com/en-us/library/2w117ede.aspx

SQL Optimization

  SQL Optimization  1. Add where on your query  2. If you remove some data after the data return then remove the remove condition in the sel...