C# and TypeScript
C#, TypeScript

TypeScript and C# both were created by the same person named Anders Hejlsberg 👏 💪 🔥(with video)

I went to one TypeScript meetup recently and talked to a few developers there.

Surprisingly, a lot of people don’t know that both languages were designed by the same person.

Yes, his name is Anders Hejlsberg

Continue reading
C#, Cross Domain, HTML5, JavaScript, NodeJS

Visual Studio Code – A Cross Platform Code Editor built with Chromium

Microsoft has launched VSCode few weeks back for Cross Platform (Linux/Mac,Windows) and 55% download was Non-Windows. Shocking , right ?

HackerNews had a post on this and had really lot of comments/traffic on it.

Lets see the first look of Code.

Continue reading


Gravatar – Get avatar by email in C# and check available or not

gravatar.com is very popular now a days. So many large sites use this feature . I needed this feature in one of my working projects

But I needed to check also that email exists in Gravatar or not. If Gravatar does not have that email Id of the user , The app will show its custom Image . But If we call the Gravatar API , Gravatar sends a default image if that email is not available which was not our app’s behavior , so I needed to track and validate that.

UTF8Encoding encoder = new UTF8Encoding();
            MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
            byte[] hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(email));
            StringBuilder sb = new StringBuilder(hashedBytes.Length * 2);
            for (int i = 0; i < hashedBytes.Length; i++)
            var imageHashCode = sb.ToString().ToLower();
            string gravatarImageUrl = "http://www.gravatar.com/avatar/" + imageHashCode + "?d=404";
            var uri = new Uri(gravatarImageUrl);
            using (WebClient client = new WebClient())
                    var imageByte = client.DownloadData(uri);
                    var headers = client.ResponseHeaders;
                    if (headers != null && headers["Content-Disposition"] != null)
                        var header = headers["Content-Disposition"];
                        if (header.Contains(imageHashCode))
                            MemoryStream memoryStream = new MemoryStream(imageByte);
                            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(memoryStream);
                            BitmapSource image = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                            return image;
                catch (Exception ex)
                    return null;
                return null;

Check the URL generation part in the code , I have used ?d=404 . This is the main thing which does the trick so that it returns 404 if that email address does not belong to Gravatar

But if anyone needs the default behavior of Gravatar , then just remove ?d=404 from the URL . It will show the default image if the email is not available.

Hope , this helps.



RDLC : Web.config Settings for ReportViewer

We, .Net Developers always do many kind of reports using RDLC . But while developing , we get the below error If we do not add web.config entries correctly .

We may get runtime error like below :::

The Report Viewer Web Control HTTP Handler has not been registered in the application’s web.config file

add name=”ReportViewerWebControlHandler” preCondition=”integratedMode” verb=”*” path=”Reserved.ReportViewerWebControl.axd” type=”Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”

To resolve this issue , add these below Nodes to Web.Config.

      <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />



      <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler,   Microsoft.ReportViewer.WebForms, Version=,   Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"  />

Cheers 🙂