Tonight is the first night without my TV. Yep, it’s gone. I gave my Philips 32” widescreen away for free yesterday and tonight reality kicks in. I start to wonder if it is possible to live without a TV while sitting here on my couch writing this. It’s sooooo quite.
Everyday I read 10 RSS feeds, read 2 online newspapers, follow tech stuff on 5 websites and watch the news on TV in the morning and at night. That covers the basic information, but then there are all the work related websites I find on Google each and every day. They vary from 3 to 50 depending on what problem I’m trying to solve.
E-mail from various people – work related, BlogEngine.NET related or from friends and family. Then add the text messages and phone calls combined with Skype and instant messaging.
I’m getting stress just thinking about all that information I need to process every day.
Out with the TV
The TV was the least important information channel, so I just thought it was the easiest to get rid of. I can’t get rid of my phone, e-mail or instant messaging because I use those at work. The RSS takes no time and I need to follow the tech stuff to keep up with the business.
After taking the decision I borrowed and bought some books just to make sure I wouldn’t get too bored.
We geeks need our gadgets and without the TV, something needs to take its place. Otherwise I’m down a gadget and that’s just wrong. I’ve set my mind on a Windows Home Server for my home network, but I’m not sure it has been released yet. It probably will very soon. Also, I would need a digital wi-fi radio to play my MP3’s. That should be enough to keep my gadget-meter point the right direction – up, up, up!
It’s still strangely quite here on the couch or should I say nice and peaceful…
Some web applications need to impersonate a user account for one reason or another. This is done from web.config and could look like this:
<identity impersonate="true" />
The impersonation works fine, but if you create new threads manually you would lose the impersonation if you don’t move it along to the new thread. This gave me a severe headache before I figured out how to pass the impersonation to the newly created thread.
What you need to do, is to pass the WindowsIdentity
object to the new thread and from there impersonate again manually. Here is an example of how to do it using the ThreadPool:
public void StartAsyncCall()
System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
private void RunAsyncCall(object stateInfo)
System.Security.Principal.WindowsIdentity identity = (System.Security.Principal.WindowsIdentity)stateInfo;
As you can see, it is pretty simple once you know how.
ASP.NET has an outgoing connection limit which is set to 2 connections by default. It means that the ASP.NET process does not create more than 2 concurrent connections simultaneously, but instead queues them up.
Consider the scenario where you call 4 web services asynchronously from the same method. What happens is that the first two starts to execute, while the next two waits for the first two to finish. The same thing happens for HttpRequests.
That is a waste of time in most cases, so you can raise the connection limit to allow more simultaneous reqests in the web.config.
<add address="*" maxconnection="8"/>
Every asynchronous request is started in its own thread, so you have to be careful not to raise the limit too far. The more CPU’s or cores the web server have, the higher can you set the connection limit.
You can read more about asynchronous requests and the connection limit on MSDN.
I’ve been fiddling with accessibility standards and validation today. It’s something I’ve been doing for several years now on many different types of web applications. So today it was time for my blog to go through validation and it almost did.
First, I started out with the Section 508 standard, which as far as I know only applies in the US, but nevertheless it is an accessibility standard and I know it is much more forgiving than WAI. It passed the Section 508 without I had to change anything, so that was easy.
Then it was time for the WAI validation. It is not as forgiving as Section 508 and in Europe all public websites have to be valid WAI double A, which is the medium accessibility grade. I ran the Bobby validator and it didn’t even validate for single A. However, that was an easy fix.
Then I moved on to WAI double A and ran into serious trouble. It validated except for this rule: Do not use the same link phrase more than once when the links point to different URLs. This is impossible to fix, because at the bottom of each post there is a Permalink, Post RSS and Comments link which are almost the same for each post even though they point to different locations. Also, some tags are the same as a category, but again, they point to different locations.
Sticking with WAI A
So, I was left with a choice. I could change the text of the links or accept that my blog does not validate WAI double A. The problem is, that you cannot have triple A valid markup if you don't pass the double A validation. I came to the conclusion that renaming the links would be ugly and do more harm than not validating, so it all ended right there. I have to settle for a single A and a Section 508 valid website. It could be worse.
Then I saw that W3C has released a beta version of their new markup validator, so I decided to give it a go. As I hoped, my blog validated perfectly XHTML 1.0 Transitional. I was then pointed to the Semantic Data Extractor which exposes the semantics of a webpage to give you a clear picture of how the text is structured. Here is the semantics of my blog. It looks quite nice I guess.
I like validating markup and always have. It has some meditative quality about it.
Some people have asked me how BlogEngine.NET displays a dropdown list of countries when no source XML file is present. The simple answer is that you don’t need any external list to bind to from C#, you can instead use the CultureInfo class.
Consider that you have the following dropdown list declared in an ASP.NET page:
<asp:DropDownList runat="server" ID="ddlCountry" />
Then from code-behind, call this method which binds the countries alphabetically to the dropdown:
public void BindCountries()
System.Collections.Specialized.StringDictionary dic = new System.Collections.Specialized.StringDictionary();
System.Collections.Generic.List<string> col = new System.Collections.Generic.List<string>();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures))
RegionInfo ri = new RegionInfo(ci.LCID);
ddlCountry.Items.Add(new ListItem("[Not specified]", ""));
foreach (string key in col)
ddlCountry.Items.Add(new ListItem(key, dic[key]));
if (ddlCountry.SelectedIndex == 0 && Request.UserLanguages != null && Request.UserLanguages.Length == 5)
ddlCountry.SelectedValue = Request.UserLanguages.Substring(3);
The method first adds all the countries from the CultureInfo class to a dictionary and then sorts it alphabetically. Last, it tries to retrieve the country of the browser so it can auto-select the visitors country. There might be a prettier way to sort a dictionary, but this one works.