Andrei Alecu

This user hasn't shared any biographical information


Posts by Andrei Alecu

How to improve your YSlow “Add Expires Header” score in ASP.NET using T4 templates

February 25, 2010 - 10:28 am

Tags: , ,
Posted in .NET, Performance Optimization, Web Development | No comments

If you care about your website performance, I’m sure you must know about the YSlow addin for Firebug.
One of its recommendations is to add an Expires header with a far future expiration date for your static content. You can read more about it here.

If you use CSS for your layout (which you should) you are [...]

Verbose steps to migrate a Silverlight application from .NET RIA Services (July 09) to WCF RIA Services (PDC 09)

November 25, 2009 - 3:25 pm

Tags: ,
Posted in .NET, C#, Silverlight, ria services | 10 comments

These are the steps I had to go through to migrate a Silverlight application that was running on the .NET RIA Services preview released in July 09, to the new WCF RIA Services released during PDC 09:

Delete all HttpHandler references to DataService.axd from your web.config. Basically, these two need to go:
<system.webServer>

<handlers>
[...]

Workaround for Silverlight RIA Services DateTime discrepancy between server and client

November 25, 2009 - 8:07 am

Tags: , , ,
Posted in .NET, C#, Silverlight | 2 comments

While working on a Silverlight application. I discovered that all the dates displayed in my DataGrid were skewed by a few hours from the real date stored in the database. Upon a closer look I noticed this skew was closely correlated to the time difference between the server’s time zone and the UTC date.
I needed [...]

Extension method of the day: Inline using() { } block in C#

November 18, 2009 - 7:20 am

Tags: , , , , , ,
Posted in .NET, C#, Code Snippets | No comments

Linq-to-SQL is our ORM of choice until the Entity Framework matures – and in our projects we use a factory method to get a new reference to our database data context. Here’s what I mean:
var db = Database.GetDataContext();

The DataContext class implements IDisposable, which means that (usually) it should be wrapped in an using [...]

Easiest way to run IE6 on Windows 7 to test your websites.

November 14, 2009 - 9:19 am

Posted in Uncategorized | No comments

Although every neuron in my brain is trying to fight me from writing this post, I realized that in our company, the websites we produce are not necessarily for computer literate people.
A huge chunk of our visitors still use IE6 and we need to provide them with a decent experience. We do have some [...]

Elegant foreach () with an index

November 13, 2009 - 10:43 am

Tags: , , ,
Posted in .NET, C#, Code Snippets | No comments

I’ve seen various ways of handling the lack of support for an index in the foreach () construct over the years.
By far the most used strategy is to declare an index yourself and increment it at the end of every loop iteration. Let me demonstrate:
static void Main(string[] args)
{
var range = Enumerable.Range(0, [...]

Beware of the Lazy<T> .NET 4.0 type. The closure trap.

November 12, 2009 - 9:42 am

Tags: , , , , ,
Posted in .NET, .NET 4.0, C#, Code Snippets | 1 comment

The System.Lazy<T> type in the new .NET 4.0 framework came to my attention recently. This type is not at all revolutionary. In fact, everyone could have written it themselves in under 10 lines of code going as far back as the .NET 2.0 framework.
Some less experienced programmers won’t realize however, that deferring the call to [...]

Introduction

November 12, 2009 - 9:39 am

Posted in Misc | No comments

Welcome to our blog. *yawn*
Please head over to the About page to see more about what this blog is about.
This post is not too exciting, but the About page is! So head over there now!
Do it!
Come on, Do it!
Do it!