Friday, March 8, 2013

How to Get MD5 hash value of a file using CSharp (C#)

When transferring a file through internet there is no guarantee that the file will be secured till it reach the receiver. It may be attacked by any virus or hacker. So the receiver should ensure whether the received file is secured or it attacked. To ensure that before transfer the file we have to get the MD5 hash value of the file. Then after receiving that file the receiver should get the MD5 hash value. If the both hash value is same means the file is secured one. Else it’s an attacked one.
Below is the CSharp code to find the MD5 hash value of a file,
public string GetMD5HashOfAFile(string file)  
{  
    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();  
    FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read, 8192);  
    md5.ComputeHash(stream);  
    stream.Close();  

    byte[] hash = md5.Hash;  
    StringBuilder sb = new StringBuilder(); 
 
    foreach (byte b in hash)  
    {  
        sb.Append(string.Format("{0:X2}", b));  
    }  

    return sb.ToString();  
}  

Wednesday, March 6, 2013

Default Web Site not found in IIS 7

I recently had a problem that i couldn't find the "Default Web Site" under Sites tree view in IIS 7 and i found the solution too.

To Solve this we have to re install the IIS and WAS (Windows Process Activation Service)
To do this,

  • Go to Control Panel
  • Make sure the View By filter is set to "Category"
  • Click the Program link
  • Under the Programs and Features click "Turn windows features on or off link"
  • A window will popup
  • There uncheck the Internet Information Services and Windows Process Activation Services checkbox
  • Restart the system
  • Then recheck the check box you have unchecked(IIS & WAS)
  • Now check the Default Web Site in IIS, that will be there!

Friday, March 1, 2013

(Solved) Error: 503 Service Unavailable in IIS7

Solution:

  • Go to IIS
  • Select the Application Pool in the left side
  • Select the application pool that you are using for your application
  • Start the application pool if its stopped