Thursday, June 25, 2009

Linq : Select minimal element from collection by some criteria.

This task was a bit tricky for me but at the end I sorted out.

It should look like similar to code snippet below:

List<Price> list = (from prices in ProductPrices where prices.NetPrice == ProductPrices.Min(minPrice => minPrice.NetPrice) select prices).ToList<Price>();

Inner selection sorts all problems :)

Cheers

Tuesday, June 16, 2009

YSlow ASP.Net problems

I've recently expired problems with asp.net web page when I realized that for some reason it loads twice per request. Every time I was in debug mode and I reload page either by pressing F5 or by pressing Enter button in firefox I got my breakpoint on Page_Load method hits twice. When I first time open page in browser everything works fine and Page_Load is called only once.

There is couple of steps to follow in this kind of scenario and as usual I started with looking into code. Soon I realized that code can't be a reason for double loading of page since code is pretty simple.

Then I tested web page from other browsers (IE and Chrome) and everything works fine. Ha, it has something to do with Firefox :).

After some time I ran Fiddler in order to trace communication between client and server and again mystery wasn't solved. There was only one call from client to server.

Then colleague told me: "Why don't you check add ons in firefox?"( Roman thanks :) ). As a "crazy about add ons" developer I have more then 15 add ons inlcuded into Firefox. I disabled them all and problem was solved. Ha!. It has something to do with add ons.! :)

I turned off/on every add on I have in firefox and after some time I realize that problem happens only when YSlow is enabled.

And then I realize that YSlow (which I installed a day before and didn't try to use yet) has setting like "Autorun YSlow each time a web page is loaded".

After hour or two problem was solved. Still I don't know why this only happend when I reload existing page.





Cheers, dear readers :)