Monday, August 14, 2006

The Atlas update panel

The technologies comprising AJAX have been around for several years, but their inherent complexity forestalled widespread adoption. AJAX frameworks are designed to make AJAX development easier. It is these frameworks that enable the whole Web 2.0 motion (and corresponding hype).

Still, even with a framework client-side development with Javascript and its ideosyncracies and limited tool support remains challenging when compared with the control centric, object-oriented approach made popular by ASP.NET.

Atlas is Microsoft's AJAX framework, based on ASP.NET 2.0. It comes with server-side controls that encapsulate the client-side functionality. Most useful is the UpdatePanel control, that allows the developer to convert any events raised from traditional ASP.NET server controls from full page postbacks into flicker-free AJAX-style partial page updating.

Using the UpdatePanel you can improve almost any ASP.NET page that does postbacks to update its contents. You don't have to be an AJAX insider nor a Javascript wizard to achieve this, any developer familiar with ASP.NET should be able to use the UpdatePanel. While Atlas is still in beta, or technology preview as these things are called nowadays, it comes with a go live license and is stable enough to be used in production sites now.

Bertrand LeRoy and Matt Gibs who are working on the UpdatePanel control at Microsoft have written an O'Reilly shortcut "Atlas UpdatePanel Control" that shows you how to apply the UpdatePanel. After some introductory explanations they show three well-chosen real-world examples, that are so close to common ASP.NET pages that you immediately understand how to apply the UpdatePanel in your own websites. The examples also include many tips and best practices on other aspects of ASP.NET and Atlas programming, with references for further study.

Shortcuts are short introductions to a brandnew topic that you can download as a PDF file. Until a book with a complete coverage of the Atlas framework and corresponding control toolkit comes along, this one shows you all you need to know to get going with the update panel, and is highly recommended.

Wednesday, August 09, 2006

RSS anywhere

One scenario the Windows RSS platform does not solve is accessing your feeds from anywhere. It allows you to subscribe to feeds on one Windows machine, and lets all applications on that machine access this feed store. However, if you are on another machine, you cannot access it.

I am using NewsGator to access my feeds from anywhere. I subscribed for free to a NewsGator online account, imported my OPML without problems, and can access my feeds now at home, at work, in an internet cafe.
I have a nice feed list in the browser, which just displays unread items, latest on the top, and I can open up the linked web pages in new tabs with IE7. If there are many news items, they put them in several pages, and you can mark all items on a page as read with one click. The read/unread status is also persisted online, so if you go to another machine, you will always see only the new items.

They even have a free news reader for Windows XP Media Center Edition. I don't like to read news items on the TV, but I created a second NewsGator online account and just subscribed to the Channel 9 video feed. I can watch the Channel 9 videos on my TV that way.

NewsGator has announced plans to integrate with the Windows RSS platform. Microsoft has similar ideas with Windows Live, but Niall Kennedy now announced he is leaving.

I still think the Windows RSS platform is a good idea, but for now I am reading my feeds with NewsGator.

Monday, August 07, 2006

How to localize the ReportViewer control in ASP.NET 2.0

The ReportViewer control in ASP.NET 2.0 allows you to display SQL server reporting services style reports. The reports can come from a SQL server reporting service (server mode), or from the website itself (local mode).

If you run the ReportViewer in local mode, you can also bind it to your business logic directly, instead of having to bind it to a database directly.

I found localizing the reports a bit tricky and not well documented, so here is a step by step guide:

  • When I installed Visual Studio 2005, only the English version of the report viewer itself was installed. The toolbar buttons for searching, exporting, etc. were displayed only in English. First you have to download and install the Microsoft Report Viewer Redistributable 2005. You will need to install this even if you have Visual Studio 2005 installed, as otherwise the installation of the following download will crash (at least it did that on my machine).

  • Now you can download the Microsoft Report Viewer 2005 Language Pack. Go here, choose the language from the dropdown, download and install for each language that you want to support.

  • If you run the report viewer now, you can see the localized toolbar.

  • In order for the report itself to display localized formats for currencies, dates, etc., make sure you have set the Language property of your report either to default, or to the desired language. This property is initialized to English if you use the English version of Visual Studio.

  • You also have to make sure that the thread is using the correct culture settings. This will default to the setting of your server. You can override it with the language the user has selected in his browser by doing something like

    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);
    Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);

    in a suitable place, like the page load or session start.

  • Finally, make sure you use culture aware formatting settings in your report, for example "C" for currencies.

Saturday, August 05, 2006

The Windows RSS platform and DTDs

I really like the idea of the Windows RSS platform. One central feed store on your machine, which each application can access.

What I don't like about the Windows RSS platform is, that it does not support feeds with DTDs. If you use IE7 to go to a feed that uses a DTD, you will get the following error displayed:

Internet Explorer does not support feeds with DTDs.

When I imported my OPML into the Windows RSS platform using IE7 (see my description here how to do that), several feeds would not display.

I did ask the Windows RSS team why these feeds are not supported. Here is the reply from Walter von Koch:

You are correct that the RSS Platform does not support feeds with DTDs. This is an unfortunate limitation based on the technology used for parsing feeds. Specifically, certain version of MSXML do not allow for DTDs being ignored. In later versions of MSXML it is possible to ignore DTDs. We are looking into possible using such flag. However, it would only work if that newer version of MSXML is installed on the machine.

With previous versions of IE, it was common to ship a new version of MSXML. See this knowledge base entry for a list of IE and MSXML versions.

However, apparently Microsoft customers got some problems with existing applications when a new version of MSXML was installed. Walter von Koch:

Redistributing new versions of MSXML is not a trivial undertaking. MSXML is the basis for many corporate applications and many enterprises tightly control which versions of MSXML are allowed on their machines. Hence, having IE7 require and install a new version MSXML can have significant impact on many customers.

Sounds like some DLL hell issues.

Why does the Windows RSS platform have to ignore the DTD? Turns out, parsing a DTD is a security issue. You can create a DTD that is so complex, that the computer parsing the DTD will use all its memory and CPU. So by creating a malicious DTD, you can run a denial of service attack against all parsers of this DTD.

My next idea was to strip the DTD reference from the feed's XML, as parsing the feed should be possible without a DTD. Turns out that this is easier said than done, too. Walter von Koch also replied to this idea:

Stripping out the reference to a DTD is not a simple task. Unfortunately it's not just applying a simple regex and strip the DTD. Parsing of xml is actually a non-trivial task given the number of encodings etc. Getting it right, and making sure it's done in a secure and safe way is challenging. Hence, the RSS Platform relies on MSXML for the xml parsing.

Recently, several of the sites I had problems with, now support an alternate feed without a DTD. In IE7, if you are on a site with multiple feed formats, the feed icon shows a drop down menu where you can choose between the different formats. So maybe by the time IE7 ships, this will be mostly a non-issue.

However, I still hope that IE7 will support feeds with DTDs, at least if an updated MSXML version is already installed on the system.