Thursday, 30 November 2017

IIS 10: HTTP Error 500.19 - Internal Server Error


Search for "Turn windows features on or off"
Check "Internet Information Services"
Check "World Wide Web Services"
Check "Application Development Features"
Enable all items under this

Monday, 20 November 2017

The remote server returned an error: (403) Forbidden



Go to run
type: services.msc
Search for below service and start
SQL Server Agent (MSSQLSERVER)
Now you should not get any error

Friday, 17 November 2017

C# shim not working in VS 2015

Go to Test Project.
Delete all files under "Fakes" folder
Remove all Fakes references from "References"

Under reference -->Right click add new reference, browse
Select:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PublicAssemblies\Microsoft.QualityTools.Testing.Fakes.dll
This should be 12.0.0.0

Go to references right click on Dll Select "Add Fakes Assembly"

Now you will see new references with name .Fakes and under "Fakes" folder new files will be added

Now build and run test cases.


It should work fine

Monday, 13 November 2017

SQL injection

using (MySqlConnection objConn = new MySqlConnection(ConnString))
{
   
// string sql = "SELECT UserId FROM User WHERE " + "(email = '" + email + "' AND " + "password = '" + password + "')";//Never use this way, it will leads to SQL injections
    string sql = "SELECT UserID FROM User WHERE email = @email and password = @password "; //This way we r createing SQL statement dynamically
    using (MySqlCommand cmd = new MySqlCommand(sql))
    {
         cmd.Connection = objConn;
         cmd.Parameters.AddWithValue("@email", email);
         cmd.Parameters.AddWithValue("@password", password);  
  try
           {
             cmd.Connection.Open();
             var userId = cmd.ExecuteScalar();
         }
         catch (SqlException sx)
         {
             // Handle exceptions before moving on.
         }
     }
}