Emil Stoichev's Blog

Just a few coding tips

  • MVP Award

    I was presented with the 2009 Microsoft MVP award earlier today! That's pretty exciting for me and I'm glad that my contributions to both online and offline communities were valued so high. I got the award for my contributions in the Silverlight community so I'm a Silverlight MVP. Thanks all for the support! See you Emil

    Read more...

  • Silvester - Silverlight Twitter Widget

    Updated to Silverlight 2 RTW!

    Since I started using Twitter I've been looking for a cool Silverlight widget I can put on my blog. Well, I found only Flash widgets so I just built a Silverlight one by myself.

    I wrote an article in SilverlightShow.net how it is implemented and provided a full source code for the widget. Read how to put it on your blog and how to build it by yourself.

    Unfortunately I'm not able to place it on this blog because of the shrunk CommunityServer features available to me.

    Read more...

  • 2008 Launch

    8f04d0a7-f17e-4146-9b93-59e0697c1936 I've just registered for the 2008 Launch in Athens. I guess most of you are exciting about MIX08 now but I won't be able to join this event and I'll have to satisfy myself with the 2008 Launch and I hope with the REMIX. I'm sure it will be fun so if you are somewhere near Athens be sure to attend. The event is free of charge. Check out the sessions here.

    Read more...

  • Tip: How to get the client culture from an ASP.NET app

    I fall in a couple of situations where I needed to get the client’s culture from the server side in an ASP.NET application. I googled this and found only client side solutions, but I knew there was some way to get this information because the ASP.NET framework supports client based culture (through the (UI)Culture = "Auto" in the page attributes and the globalization section in the web.config). The only way I thought of getting the client culture was from the Request object.

    After examining the HTTP Headers collection I found the Accept-Language header. It contains information about the user's preferred languages. This is a sample Accept-Language header:

    Accept-Language
    bg-BG,en-US;q=0.7,ar-BH;q=0.3

    The languages are explicitly defined in the browser and their order is determined. You are probably wondering what this q-thing means. According to the RFC 3282 (Content Language Headers) it specifies the language quality or in other words the language priority set in the client's browser. In the example above bg-BG (Bulgarian (Bulgaria) has highest priority then en-US (English (United States)) and the last preferred language is ar-BH (Arabic (Bahrain)).

    The Accept-Language header lists all languages set in the browser in a comma separated list which makes it easy to extract each language.

    From ASP.NET you can access this header using the Headers collection in the Request object - Request.Headers["Accept-Language"]. Then you can process it the way you like.

    UPDATE:
    Raj Kaimal gave a useful tip that instead of using Request.Headers["Accept-Language"] you can simply use the HttpRequest.UserLanguages to get a sorted string array of client language preferences. Thanks Raj!

    I hope you find this tip useful.

    Read more...