Monday 30 September 2019

How to find Windows key using Command prompt in windows 10

///////////////

Step 1. Window-key+R
Step 2. Type cmd inside the dialog box
Step 3. Press inter-key to open the Command Prompt window
Step 4. Copy and past the below line and press Inter-key

wmic path softwarelicensingservice get OA3xOriginalProductKey

Step 5. Next line is your windows key

How to find Windows key using Windows Registry method in windows 8.1

///////////
Step 1. Open Notepad on the desktop.
Step 2. Copy below text and past in notepad.

Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))

Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
x = 14
Do
Cur = Cur * 256
Cur = Key(x + KeyOffset) + Cur
Key(x + KeyOffset) = (Cur \ 24) And 255
Cur = Cur Mod 24
x = x -1
Loop While x >= 0
i = i -1
KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
If (((29 - i) Mod 6) = 0) And (i <> -1) Then
i = i -1
KeyOutput = "-" & KeyOutput
End If
Loop While i >= 0
ConvertToKey = KeyOutput
End Function


Step 3. Go to Edit tab >>  Select Save as

Step 4. Save with the name productkey.vbs on he desktop.

Step 5. Double click on the file to get the windows key


Thursday 26 September 2019

How to remove “Server name” or items from history drop-downs of SQL Server Management Studio

////////////////


Here is simplest way to clear items from this list.
  1. Open the Microsoft SQL Server Management Studio.
  2. Click on Connect to Server dialog (File->Connect Object Explorer, Object Explorer-> Connect-> Database Engine, etc).
  3. Click on the Server Name field drop down list’s down arrow.
  4. Hover over the items you want to remove.
  5. Press the delete (DEL) key on your keyboard.

Wednesday 18 September 2019

Encrypt and Decrypt web.config using asp.net

////////////////



 public static void EncryptConnString()
    {
        string msg="";
        Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
        ConfigurationSection section = config.GetSection("connectionStrings");
        if (!section.SectionInformation.IsProtected)
        {
            section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
            config.Save();
        }

        ///////////// or

        Configuration config1 = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
        ConfigurationSection configSection = config1.GetSection("connectionStrings");
        if (!configSection.SectionInformation.IsProtected)
        {
            configSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
            config1.Save();            
            msg="ConnectionStrings has been encryted successfully.";
        }
        else
        {
            msg="ConnectionStrings Already encryteded, this action has been cancled";
        }
    }


    public static void DecryptConnString()
    {
        string msg = "";

        Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
        ConfigurationSection section = config.GetSection("connectionStrings");
        if (section.SectionInformation.IsProtected)
        {
            section.SectionInformation.UnprotectSection();
            config.Save();
        }
        ///////////////// or

        Configuration config1 = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
        ConfigurationSection configSection = config1.GetSection("connectionStrings");
        if (configSection.SectionInformation.IsProtected)
        {
            section.SectionInformation.UnprotectSection();
            config.Save();
            msg = "ConnectionStrings has been Decrypt successfully.";
        }
        else
        {
            msg = "ConnectionStrings Already Decrypted, this action has been cancled";
        }
      
    }


/////////// Result



///////////--------Original 

     <connectionStrings>

     <add name="ConnDB" connectionString="Data Source=Abc;Initial Catalog= Main;Integrated Security=True;Connect Timeout=500" providerName="System.Data.SqlClient"/>
  </connectionStrings>



///////////--------Encrypted


 <connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">

    <EncryptedData>
      <CipherData>
        <CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAYGhwDVq4A0K6/N1Iz7hkjwQAAAACAAAAAAAQZgAAAAEAACAAAAAQLUts2b81u6QlaWMSfIVR0iBp5su9KGX2i+VpML9lngAAAAAOgAAAAAIAACAAAACkbblBrg5LRH7smCEsfCzed1UAMo3xxqodk5FCFpCjWWADAACbZIl/yzrSLQGte1E4pPf/s3NkdZToUIS5RgXFrNBPXQNLIPEpU/GaVvRuWkc5Yz24ICYDFq2O8nfcuVwr9Jj2Edx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alWw5ZWqlzwxFMnV3Fo2ow7jCGBuo/qqomAxxmQS3zAhfREHlPGZuzKkcASqnuS+XIoFPKWUIePBTQ==</CipherValue>
      </CipherData>
    </EncryptedData>
  </connectionStrings>

Thursday 5 September 2019

CS0103: The name 'Styles' does not exist in the current context

/////////////////
Step. 1- Install the fallowing Using Nuget
              Microsoft.AspNet.Web.Optimization

Step. 2- Install the fallowing Using App_Start/BundleConfig.cs

public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                        "~/Scripts/jquery-ui-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                      "~/Scripts/jquery.unobtrusive-ajax.js",
                      "~/Scripts/jquery.validate.js",
                       "~/Scripts/jquery.validate.unobtrusive.js",
                        "~/Commons_JS/Common.js"
                      ));
           
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

            bundles.Add(new ScriptBundle("~/bundles/JS").Include(
                             "~/js/jquery-3.2.1.min.js",
                             "~/js/popper.min.js",
                             "~/js/bootstrap.min.js",
                             "~/js/main.js",
                             "~/js/plugins/pace.min.js"
                         ));

            bundles.Add(new StyleBundle("~/bootstrap/css").Include(
                      "~/css/bootstrap.min.css",
                      ));


        }


Step. 3-  Add the following line to your Global.asax.cs
          
            BundleConfig.RegisterBundles(BundleTable.Bundles);


Step. 4-  Add the following line to your View/web.config file
             
<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Optimization"/>
      </namespaces>
    </pages>
  </system.web.webPages.razor>



Step. 5-  Add the following line to your web.config file

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">     
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...