Monday, 25 January 2010

Microsoft recently release it's Search Engine Optimization Toolkit as part of the Internet Information Services. Making SEO Toolkit part of IIS is a strange decision to start with, and reasons for that are beyond me. To work around this "issue" I've invested some time to make it possible to use the same functionallity online via a web application. So with no further adieu I present to you the Search Engine Optimization Tools - Online.

SEO Tools I just made available is a first step in building a comprehensive workshop for professional web developers who are not pro at SEO.

Comments are welcome!

Monday, 25 January 2010 01:09:59 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 
 Wednesday, 20 May 2009

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.
Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out FREE licenses to bloggers and their readers.
The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.
Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.
The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you'll get a license automatically (even if more than 60 submit) during the first week of this announcement.
Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.
Go ahead, click the following link for more information on how to get your free license.

Wednesday, 20 May 2009 15:49:35 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 
 Wednesday, 25 June 2008

I'm sure most of you know about podcasts. Sites like .NET Rocks being one of the most popular for .NET developers. Sooner or later though, you just run out of podcasts. Especially if you, like me, try to waste no time - which includes walking your dog with an MP3 player plugged in :-)

There are also cases when the level of podcasts is way below what you would expect. Once you get a certain level of expertise in any subject, most of the podcasts start to sound lame and that is natural of course - a sign of you progress.

Worst case scenario however is, when there are no audio materials on the subject of interest. Been there, seen that, solved it.

Enter SpeechR.

A small tool that I wrote mostly for myself. SpeechR is a tool that allows me to take any text and convert it into an audio format (wave or mp3) so I can later put it on my MP3 player and listen to while... whatever I do that doesn't require focus.

With all the ebooks out there, with all those lenghty manuals or blog posts and a comming vacation on a beach... What more can a hardcore can you want.

Tool uses System.Speech namespace that was introduced with .NET 3.0 to generate sounds. System.Speech in turn uses Microsoft Speech API found in Windows. With version 5 it got pretty good. Just compare Microsoft Anna in Vista to Microsoft Sam in XP.

Of course, Microsoft's voice isn't perfect - far from it. There are however commercial voices out there that are very good and cost ~30$.

Well. The tool is free, you can install it and enjoy. Please let me know what you think about it and what features you would like to see in v.Next().

Wednesday, 25 June 2008 19:37:27 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 
 Tuesday, 24 June 2008

I'm having some very strange problems lately with my Visual Studio. From time to time, a random feature just stops working. From not being able to pin/unpin windows, through random component not installed/missing, to just not being able to even start the IDE.

Some of the problems go away after restarting Visual Studio. Some of the problems go away after restarting Windows. Some of the problems just STAY!

After asking "Deep Thought" for the ultimate answer to life, I got it, and it was 42...

Naaah. Actually asking google was helpful in a way. It gave me some clues on what can I do to "reset" Visual Studio without reinstalling it or even worse, the whole Windows. The answer was:

devenv /resetskippkgs

Remember this one. You will need it. Sooner or later, but you will. It solves a lot of different issues.

Tuesday, 24 June 2008 21:08:45 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 

"Invalid URI: The Uri scheme is too long" - now that's a peculiar message. I got it while doing some Xslt transformations. It comes out that XslCompiledTransform can't just read any xml and transform it. There are issues if Uri scheme is too long. What is too long? Can't really tell, since mine wasn't THAT long.

The following code did not work for me:

XslCompiledTransform xsl = new XslCompiledTransform();
XmlWriter writer = XmlWriter.Create("dest.xml");
xsl.Transform(File.ReadAllText("source.xml"), writer);

So I had to use this one:

XslCompiledTransform xsl = new XslCompiledTransform();
using (XmlWriter writer = XmlWriter.Create("dest.xml"))
    using (XmlReader reader = XmlReader.Create("source.xml"))
        xsl.Transform(reader, writer);

The problem is the Transform method and File.ReadAllText that returns the whole source xml string at once. XslCompiledTransform just can't handle it for some reason.

Tuesday, 24 June 2008 21:01:05 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 
 Saturday, 31 May 2008

Now! That has to be one of my greatest findings! Ever!

The Indexer method (the one that allows for doing object[something]) of the Hashtable class in .NET has a Thread.Sleep(1) inside one of the loops!!!!

Yes I repeat Thread.Sleep(1)!

Why would anyone want to insert a Thread.Sleep() call in to a Hashtable, or any other BCL class for that matter, is beyond me.

Can you beat this gem?

Saturday, 31 May 2008 21:09:21 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 
 Wednesday, 21 May 2008

"There is no such method!" That's what everyone is told by Microsoft. Microsoft is even insolent enough to provide us with reasons why they did not include Directory.Copy method in .NET Framework.

I find those arguments unacceptable. Sure, they are valid at some level, but it's wouldn't be the only piece of code that goes "mainstream" and does what 99% of people would expect it to do, without considering special cases.

So I went and almost implemented my own Directory.Copy. Almost.

It came out that Microsoft does not live to its own words! There is a method in .NET Framework, that allow us to copy a directory, just like that, in one call. It is hidden in a Microsoft.VisualBasic.dll assembly in a Microsoft.VisualBasic.FileIO.FileSystem type and is called (not surprisingly) CopyDirectory.

Although it is in VisualBasic namespace, there is nothing that prevents us from using it in C#. Only a reference to an assembly is needed.

Well Microsoft? What you say to that?

Wednesday, 21 May 2008 20:07:50 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 

Another day, another gotcha.

While working with regular expressions I was matching some input string to a pattern with one group capture (is it the correct name?). I made a regex.Match() thing, got a match and since it was just a test code, I wen stright for getting the second group out of the match (first being the whole match):


I was pretty much expecting an IndexOutOfRangeException, or something similar, in case there were no matches. To my surprise I got no exception! To the contrary I got a result, an empty one, but a result.

Quick peek inside the code and it came out, that that's just how GroupCollection's indexer is implemented. It returns an empty group in case you try to get one that doesn't exist.

Is it intuitive? I seriously doubt it. That's a first time I see a collection with an indexer, that allows me to access elements by index that is beyond the collection's elements count!

I don't like when those kinds of things happen...

Wednesday, 21 May 2008 19:54:36 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 

Just few days ago, my friend at work found a peculiar error message in ASP.NET RangeValidator control. He was trying to validate length of a string in a TextBox. Controls on page definded as follows:

<asp:TextBox runat="server" ID="TB" />
<asp:RangeValidator runat="server" ID="RV" 
MinimumValue="3" MaximumValue="20" 
ControlToValidate="TB" Type="String" />

What he got was a best error message ever:

"The MaximumValue 20 cannot be less than the MinimumValue 3"

That's right! 20 cannot be less than 3!

Interesting isn't it?

I made some research of my own and I've found out that sane people should not look inside RaneValidator's (and other related classes) code! What it does inside is it uses a String.Compare to check if ranges are ok.

Of course, the problem are not the ranges, but the Type property of a validator. If set to String, it treates minimum and maximum values as strings and compares them as such - meaning that it compares character by character instead of just number to number.

That explains, why my friend got the error, but it certainly does not justify the text of the message! It might take long hours for an inexperienced developer to find where the problem lies. Come on Microsoft! You can do better than that!

Funny thing is that I never even thought about using RangeValidator to ensure string length, but suggested RegularExpressionValidator right from the start :-).

Wednesday, 21 May 2008 19:44:48 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 
 Saturday, 17 May 2008

As we all know, ASP.NET uses one form model to do all it's magic. Love it or hate it, we have to live with it. 99% of the time, it is not a problem, but then there is this 1%...

The main problem with ASP.NET's model is that the form tag has a fixed action attribute. What if we want to change it? No, there is no simple way of doing it. Solutions vary. Most common one is to create your own FormControl that inherits from HtmlForm and override RenderAttributes method. Unfortunately, inside that method, we have to do everything the original method does and only change the action attribute to the desired value. Ugly!

Another one is to provide an OutputFilter for the Response but that is also a lot of coding.

My preferred way of dealing with this issue is to provide my own, special HtmlTextWriter. Its role is to intercept the WriteAttribute method call and provide my own value. Following code illustrates the concept:

class ActionAttributeWriter
    : HtmlTextWriter
    string action;
    public ActionAttributeWriter(
        HtmlTextWriter writer, string action)
        : base(writer)
        this.action = action;
    public override void WriteAttribute
        (string name, string value, bool fEncode)
        if (name == "action")
            value = action; 
        base.WriteAttribute(name, value, fEncode);

Only thing that is needed then is to use this writer instead of a normal one. Page.CreateHtmlTextWriter can be used for this purpose:

protected override HtmlTextWriter 
    CreateHtmlTextWriter(System.IO.TextWriter tw)
    ActionAttributeWriter writer = 
        new ActionAttributeWriter(
    return writer;

Solution is not very clean and I would certainly not recommend it for a public product, but it's better than nothing.

Saturday, 17 May 2008 14:09:17 (Central European Standard Time, UTC+01:00)  #    Disclaimer  |   | 

There are a number of quality web hosting companies that provide hosting service along with selling domains and renewing expired domains. Linux is one such concept that is getting widely popular so it is recommended for web hosting companies to provide linux hosting as well. Courses on linux are available through free online learning programs. This rapid increase along with the communication advancement through internet phone and wireless cell phone has really helped in boasting e-businesses which can be further promoted through internet marketing online campaigns.