May 10, 2017

Clearing / resetting images in Outlook cache

While creating emails, quite a few times you will not see the updated images in the email. this is because Outlook caches the images. These images are displayed from the cache even for newer mails. To remove any files from cache in Windows (for Outlook 2010 and above) do the following.
  1. Close Outlook.
  2. Press "Windows+R". and type or paste the following:
    %USERPROFILE%\Local Settings\Temporary Internet Files\Content.Outlook
  3. Delete all the files and folder in this location.
  4. Open Outlook.

In Mac do the following:
  1. Right-click (or control-click) your Exchange Inbox NHSD folder
  2. Click Folder Properties
  3. Click the General Tab
  4. Click Empty Cache

May 1, 2017

ASP.Net | POST request in C# with content-type being x-www-form-urlencoded

The following code makes a POST request in C# with content-type being x-www-form-urlencoded:

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.AllowAutoRedirect = true;
webRequest.Timeout = 20 * 1000;
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
webRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36";

//write the data to post request
//Postdata : a=1&b=2&c=3
byte[] buffer = Encoding.Default.GetBytes(Postdata);
if (buffer != null)
{
     webRequest.ContentLength = buffer.Length;
     webRequest.GetRequestStream().Write(buffer, 0, buffer.Length);
}

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string strResponse = reader.ReadToEnd();