web 2.0

Url Rewriting By Scott Guthrie

At last what seems to be a throughly complete reference for URL rewriting in .Net

Tip/Trick: Url Rewriting with ASP.NET

Tags:

Windows Developer Tools Day

Apparently today is "Windows Developer Tools Day" and because I contributed to the book of the same name, I've been asked to write an entry on my favourite free tool, how it has helped me.

I use a lot of free tools, it takes me ages to install them and as I don't really keep a list it's largely an organic process. However, the tool which really sticks out in my mind is Fiddler. Basically it's a proxy which sits on your machine and logs all HTTP traffic.

So why is this useful, well sometimes you really need to know exactly what is being sent from the server to the client, especially these AJAXY days when requests to the server can happen at any time. Not to mention the rise and rise of web services. All these requests get logged by Fiddler.

The time that really sticks out as a life saver was the development of a web service client windows application which in development and release worked 100% with site 1 however with site 2 the application crashed on every call to the web service. As the development environment was a long way away debugging was discounted so I launched Fiddler and had a listen. It logged the call out, and the return from the server. The BODY of the response was fine, however, when I looked at the HTTP Header there was something very wrong. It turned out there was an ISAPI Filter at site 2 which announced itself by including an invalid HTTP Header.

The filter wasn't necessary so we removed the filter and this removed the problem. Actually I believe that the error was being thrown from a third party component and so it would have been impossible to handle the error other than by fixing the HTTP Header.

So there we go enjoy the rest of "Windows Developer Power Tools" day.

Tags:

Welsh in an asp.net website

The my valleys house website is bilingual (English and cymraeg.) I'm not a welsh speaker so it did present a challenge. However, the System.Globalization part of asp.net 2 was really helpful. So on my Windows XP SP2 development machine I was able to set the CultureInfo to auto and set the language in my browser to the correct settings and away I went, automatically the site appeared in the language defined in my browser.

This was great, until I came t orelease the site onto the live server at which point Kaboom! no welsh culture info. Wicked, I thought, atleast when I tried to find out I realised that there is support for custom cultures in asp.net 2. Unfortunately you need to own the server that you want to install the culture info - there seems to be no way other than some dubious reflection calls.

So how did I resolve the issue?

I piggy backed an existing culture that was installed on the maching. So in the Application_BeginRequest I find out what culture the client is requesting and if that happens to cy I set the thread culture to be catalans. (Catalans just happened to be the closest alphabetically.)

Argh. Anyway it all seems to be working ok and you can view the welsh version of my valleys house. If you set your browser languages to have welsh as the first entry then you'll automatically get this site.

Maybe someday Windows 2003 will have welsh installed as a culture and I can do this whole thing properly. Windows XP does have welsh but it's only included in service pack 2.

Tags:

Cor blimey, it's been a long summer

I've started my teaching course and I'm 3 weeks in to a 10 month course. So hopefully if all goes well this time next year I'll be a qualified teacher. I've a mass of work to produce in the the next few months and that's on top of lesson plans and actual teaching.

But before that I'm going to be included in an O'Reilly book. I've never bought an IT book, always preferred something with more of a story, so it's a strange to think I'll be in one of them.

Also I've spent the last few weeks developing a site for Valleys Built Heritage which is an organisation based in the south wales valleys to aid the redevelopment of the area in particular valleys houses.



Tags: ,

Where have I been, at school that's where!

Recently I've been running an evening class on a Wednesday night at Wyedean School. It's been invaluable help to me as I prepare to train to become a fully fledged high school teacher in September.

Hopefully, I'll be able to do more work on the site, I've had loads of ideas in the last 4 months, you tend to have time to think to yourself when you're stuck on a motorway for 3 hours a day. So shortly I'll be able to post some new stuff.

Things to look for are an installer for Browser Launcher and something even more incredible.

Tags:

Windows Live Mail UI update

Atlast there's room to read my mail that I get in live mail. The UI has been updated so that you can go back to the old Hotmail way, stick with the new 3 column way or change to the outlook express way (2 columns with the mail reader underneath). It still selects the top email in your list and sets it as read even if it's new in or is full of spam or what ever. I think that it would be better not to automatically select any email.

There's a little shortcut panel unfortunately there's no roll-over or mouse change on the images to indicate that you can click on them, so a little more work needed there aswell.

Still it's getting better and I have to admit that the spam filter is a damn sight better that it was previously.

Tags:

An interesting way of analyzing user activity

Dan Zambonini digs further into user activity Plotting the exact X/Y coordinates of clicks on a page.

Not sure how much use it is, but it's a fun set of data to work with.

Tags:

Google Reader - an update

I haven't been using my google reader account for about a week, and what with a subscription to the register, scoble and slashdot. It's got an x number of unread entries. (where 1000<x<10000)

While I could sift through the x entries to check I haven't missed anything, I don't really have the time, but I'd like to mark all the unread entries as read. At the moment there's no built in way to do this with google reader so I've had to rely on a greasemonkey script. (Greasemonkey is a Firefox extension which lets you to add bits of DHTML ("user scripts") to any web page to change its behavior. ) You can download the mark all read script from this site.

Tags:

DOMHelper Addins you say, how do I write one of those?

Well it's not all that difficult.

I've just created something that will enable one to view and edit any scripts that are loaded in the browser.



In essence all you need to do is to create a class library and include a reference to the DOMHelper dll. Then you just need to create a usercontrol. Design the control as usual and when you come to work on the code element make the class inherit the bho.csseditor.Plugin class.


The first method you'll want to override is the Activate method this will be called when a new document is loaded and when the tab is made visible. The title property will be what's displayed in the tab and there's a property on the base object called ParentFrame from which you can get a reference to the mshtml.WebBrowser and mshtml.Document objects.

Once you are happy about life and your coding, then you can import your shiny new plugin into the DOMHelper. To do this is actually a bit of a nightmare, much harder than I thought it would be, but I'll let you know how I managed it and you can do the same back to me:

I found out using FUSLOGVW that you may need to add the DOMHelper and interop.shdocvw assemblies to the GAC. Having thought about this again you may also be able to get away with placing your assembly in the same folder as the DOMHelper that is loaded by Internet Explorer. You'll have to try this yourself.

Anyway, once you've added the assemblies to the GAC using GACUtil (available as part of the 300Mb SDK) you can then load the assembly. Click the little monitor image and choose add-ins and follow the instructions from there.

There you go - you're up and away.

As a starter for 10 you can download the DOMScripter Visual Studio Project, which also contains a binary if you're too lazy to build the code yourself.

Any comments would be welcome.

Notes:
  • You won't be able to do anything in the designer when the the class inherits the Plugin class because it's an abstract class, ya de yada.
  • If you have a textbox on your own plugin then you may want to ensure that it receives the attention that it's due i.e. handles backspace correctly by handling the GotFocus() event and calling the ParentFrame.SetFocus().
  • You can use the CLR Debugger (also part of the SDK) to run IE and find any bugs.

Usual disclaimers apply.

Tags: , , ,

A simple browser helper object in C#

I was asked if there was a simple way to write a browser helper object (BHO) using C#.

It's actually very easy to do this if you know what you're looking for, I used the information on steven cohn's weblog everything is there that you need to write a BHO. I recommend that you read the article - it's very concise and accurate. You can download my interpretation of this BHO article in a single file. When you download this file and include it in a project you'll need to add the Shdocvw COM object and in .Net version 2 there's a .net component called Microsoft.mshtml.

It's incredibly easy to write something that will do the very simple, however when you get into messing with the mshtml and shdocvw then you may run into problems. I had terrible trouble with the DOM Helper. There's absolutely no documentation for mshtml. So most of it is trial, error and a fair bit of guesswork.

If you're looking for something quick then I would recommend that you have a stab at implementing a menu extension. They are far easier to write and can be called from the context menu of IE.


Tags: ,