Thursday, April 27, 2006


How to fix ASP.NET HTTP 400 error Bad Request errors

I was working on a system that proxied external contents when I got 400 Bad Request errors for file names with a double period; file..jpg. IIS handled the requests just fine as /dir/file..jpg worked but ASP.NET bombed when I requested /dir/proxy.aspx/file..jpg :

HTTP/1.1 400 Bad Request
Connection: close
Server: Microsoft-IIS/6.0
Content-Type: text/html

<html><body>Bad Request</body></html>

Microsoft Knowledge Base article 826437 explains how to fix it:

  • Install .NET 1.1 Service Pack 1

  • Set the following DWORD registry value: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET VerificationCompatibility = 1

You also get a 400 Bad Request error if the url contains other reserved characters like colon http://server/folder/file.aspx/

The syntax /dir/file.apx/something/else/here/123 is useful in many cases. Browsers do not see the url as "dynamic" as it does not contain a question mark so they are more likely to cache the output. The url can also be made shorter, which is important for mobile devices, as it does not have to urlencode all special characters.

Wednesday, April 26, 2006


Solution Architect Forum in Milano 19/5/2006

Solution Architect Forum: defining, building and using software factories is a free event organized by Microsoft with the help of Beat Schwegler, IT Architect - Microsoft EMEA and Ingo Rammer, Principal Consultant – Thinktecture


  • Software Factories Vision

  • Software Factories Today

  • A Software Factory to Build Factories

  • Using a Software Factory

  • Defining and Building a Software Factory

Saturday, April 15, 2006


Sydney goes to school

Or to be more correct: I go to school to be better a master. Sydney is a big dog, looks and walks like a wolf so people easily get scared.

He is pretty smart and does what I tell him to unless he is distracted. Convincing him to leave the local dog playground usually takes a while so I contacted the local office of X-Plorer to learn more about how I can make sure I am always in control. Their philosophy is to reward good behavior instead of punishing bad behavior which I agree 110% with (even though it is difficult when you come home from work to find something destroyed...)

The first lesson was completely theoretical so yesterday evening was the first real session. It started with the most basic thing; making the dog look you in the eyes when you call him. We quickly covered the basics until we got to the issue that I was most interested in: how to make the dog come to you even when it is distracted.

I learned several lessons during the one hour session yesterday:

  • Use short training sessions (5-10 minutes) and then stop for a while so the dog can rest and do something else. 5 minutes a day is better then long marathon sessions during the weekend.

  • Always reward good behavior with a sweet during the initial training (we are using small pieces of chicken sausages)

  • Never hold the sweet/reward in your hand. Always give compliments first, then take the sweet out of the pocket

  • Call the dogs name but do not give the command until it looks at you. Whistle, clap your hands or do something else to grab its attention if it doesn't turn when you call it.

  • If the dog doesn't look you in the eyes: hold the sweet in front of the dog, bring it up to your eyes and keep it there, establishing eye contact with the dog.

  • Sydney loves bringing stuff back but he wants to "fight" to release the toy. The trick is simple: bring two balls. Throw one ball and wait for the dog to come back. Then repeatedly repeat the "release" command showing him the other ball (move it to show that it is more interesting and a better ball). When the dog finally drops the ball; give compliments and throw the other ball. Pick up the ball the dog left and repeat.

  • Then the best trick of the day; how to make the dog come to you even when it is distracted. Call the dog, wait for it to look in your direction, then turn away and run away. The dog will come running to catch up. Never do what I used to do; walk towards the dog. It thinks you're coming to it so it will continue to stay where it is. The same lesson applies to giving a reward; never step towards the dog. Make it come to you.

We have 8 more sessions to go. They have an agility camp where we train which I am sure Sydney would love if we get through the basics in time.


SendKeys on .NET Compact Framework

I needed SendKeys in .NET CF when I implemented the AutoType feature in poSecrets. I found a SendKeys  implementation on OpenNetCF. It implements the SendKeys logic for handling repetitions and special keys like shift, alt, ctrl, etc but it does not support upper case/lower case and some special characters.  I thought I had to implement my own key map until I found PostKeybdMessage. It is perfect as it manages all the shift states.

I modified the SendChar routine like this and now it works like a charm:

private static void SendChar(byte k, byte [] mods)
    // Use the PostKeybdMessage() api instead of keybd_event
    // as it correctly manages upper case, lower case
    // and special characters
    //keybd_event(k, 0, 0, 0);
    //keybd_event(k, 0, KEYEVENTF_KEYUP, 0);
    uint KeyStateDownFlag= 0x0080;
    uint KeyShiftDeadFlag= 0x20000;
    uint[] buf1 = new uint[1];
    uint[] DownStates = new uint[1];
    uint[] DeadStates = {KeyShiftDeadFlag};
    int hwnd = -1;
    PostKeybdMessage(hwnd,0,KeyStateDownFlag,(uint)buf1.Length, DownStates, buf1);
    PostKeybdMessage(hwnd,0,KeyShiftDeadFlag,1, DeadStates, buf1);
    CancelMods(mods, 4);

I will send the updated code to opennetcf so I guess the code will make it into the main branch soon. In the mean time you can download the source code for SendKeys in the downloads section.

Wednesday, April 12, 2006


.NET Community days - day 1

My rough notes from today's WinForms track below.

.NET Compact Framework 2.0

The best presentation of the day: Fabio Santino which had -one- slide: Agenda: Q&A.
I have developed several applications with .NET CF so most of it was old news, but Fabio is a great presenter so enjoyed it anyway. I was particularly pleased to see that the Device Emulator in Visual Studio 2005 has improved a lot:

  • it can run multiple emulators at the same time

  • it uses a Strong ARM emulator so you can install standard pocket pc applications from the internet so you can make your own ultra portable personal pc

I didn’t know it, but the Phone edition emulators have the phone number +14250010001 so you can send/receive SMSs and simulate phone calls with the emulator

ClickOnce deployment
The previous solutions for easy deployment, like the "no touch deployment", had a lot of drawbacks so it was interesting to get some more information on ClickOnce which tries to solve most of the problems:

  • installing and running applications without being an administrator. This is particularly interesting for apps that use com objects

  • automatic updates

  • rollback to an old version in case the new version fails

Solving the problems leads to some "compromises" that not everybody in the audience agreed with but I think they are as good as they can be without installing the app the normal way. The application and data are stored in versioned directories in the documents and settings directory of each user. This makes rollbacks possible using the Add/remove software applet in the control panel. It means more disk usage as each user will have a couple of copies (current + backup) of each application and data set. On neat thing is that ClickOnce is able to run com objects without registering them on the computer using the " Interop option: Isolated=true" option on Windows XP and later

Windows Presentation Foundation
I have followed various blogs on WinFX without ever getting the WinFX bug. The demos and discussions today changed that. I have several ideas of games/tools for kids that I have been trying to implement in Macromedia Flash. I got as far as installing the demo and reading parts of a manual before I realized that Flash is a very different world for me as the terms, and especially the IDE, is completely different from everything I have worked with so far. WPF looks like the perfect thing for me as the "graphical designer" part is separated in an external xml (XAML) file that defines the look of elements, transitions (move object A from X to Y in Z seconds), styles etc.

It looks like Microsoft has Flash killer with Expression Interactive Designer. The WPF Everywhere version should run in web browsers on other platforms like Mac, Linux(?), Solaris(?)

Blogs of the presenters

The slides and material should be on the Community Days site after Easter

Sunday, April 9, 2006


New free downloads on /egilh

I have added some more applications to my download section:

  • poShoplist: A simple shopping list manager for Pocket PC

  • poToday: A “Getting Things Done“ like task manager for the Pocket PC


poToday: A GTD task manager for the Pocket PC

poToday for the Pocket PC makes it easier to focus on the tasks that are due on any given day. I have been practicing Getting Things Done ever since I got my first Palm Pilot before I knew it had a fancy name. In Outlook I use  a customized view that shows all tasks due today, grouped by priority. This feature does not exist on the Pocket PC so I implemented a simple task manager using .NET Compact Framework

poToday shows the current date with buttons to move back/forward by one day, week or month. The menu commands are pretty simple:

  • New creates a new tasks due the current day. The new task is automatically marked private
  • Scheduling lets you move the selected task to any given day of the week, or by a fixed increment like one day, week or month. The "Catch up" feature moves all expired tasks to today.
  • Priority lets you change the priority

Note that the tasks can be sorted by clicking the column heading

Changes in .NET 2.0 version:

  • The menus have been changed to better take advantage of the application buttons in Windows Mobile 5.0.
  • Added menu for moving between days, sorting. One of the things I really like with the new menus is that it allows me to do everything with the menus and hardware buttons. No need to take out the stylus.
  • The application is a lot smaller as it no longer requires and external DLL for talking to Pocket Outlook

Changes in poToday 3.0:

  • Supports English date formats

  • Added a "move to no date" feature

  • Added context support (using the categories in Outlook).

  • Support for different screen orientations and sizes

No installation required. Just download poToday and copy the .exe to your SD Card or the Pocket PC. For the .NET 1.1 version you also have to copy the correct Pocket Outlook wrapper for your platform.