Several years ago, when Java was still a toddler, probably around 2001, my brother had written a very functional downloader in Swing – it would read a text file of urls, and download each file one by one. It has been a while, that source code is gone, Swing is gone, Sun is gone, blah blah blah.

Sitting idly, I suddenly thought of that piece of code for no reason and said to myself why not rewrite that in groovy. And literally wrote this in a few minutes… The code is pretty self contained, it assumes defaults and there is even a test mode… Its been long journey with Java, yeah definitely feels like one.

This converts a command-line invoke with arguments with a hyphen character into a map of key-value. For eg:

Download.groovy -mode test -targetDir c:/downloads

will yield a map of [mode:test, targetDir:c:/downloads] Neat isn’t it? Think of how complicated a conversion of list to map in Java is.

Another is the expando, see the keys of the map are used like properties: args.mode, args.targetDir instead of args.getKey(“mode”) or args.getKey(“targetDir”).

The above feature comes very handy especially when trying to deserializing xml into objects. You just don’t do deserialization xml to java bean objects! Use directly. That way if xml changes, you do not have to generate code again (think jaxb!). Just modify your code to use the new xml tags!

Custom ASP.Net http handlers do not work in SharePoint 2010 after migration from 2007.

Premises

There are several ways one can write a custom http handler for use within a sharepoint environment.

Create .ashx file and a corresponding code behind .cs code and place it in _layouts folder. However that would not work if you dont want to expose the _layouts or you want to use a custom url mapping too (eg MyCustomHttpHandler.logon instead of MyCustomHttpHandler.ashx). So an alternative way is to create a .cs (that implements IHttpHandler) and a custom url mapping and place it in the <httpHandlers> section in web.config.

Solution

Open IIS 7 and select the SharePoint site

Open Handler mappings

Add Managed Handler

Provide a name and use the same type as used in the web.config section for httpHandlers

Restart IIS

Now the http handler will work.

Reason

When migrating to 2010, one of the changes was using the Integrated app pool instead of classic app pool. If your new site is using Integrated app pool, IIS 7 expects the handlers to be in a different section – specifically <system.webServer><handlers> section. In classic mode, the handlers are used from <system.web><httpHandlers> section.

Adding the custom http handlers within this section allowed IIS 7 to map the handler to the code.

We were migrating a sp 2007 project to sp 2010. The web.config between the two environments were very different (mainly the version numbers). After the merging the two web.config, I was getting a plain Error 500 on the site, with no further details.

Solutions:

First up, open IIS, select the site, double click on the Configuration icon. If this opens, at least the web.config is fine. In my case even this did not open up, and gave an error 0x8007000D and very helpful error of empty string.

Scouting around on several websites, (the most helpful was stackoverflow.com) finally tried installing the IIS7 rewrite module (rewrite_2.0_rtw_x64.msi) and restarted IIS. Now I was able to open the Configuration Editor from IIS7.

Now hitting the site gave atleast a readable error “System.Web.Extensions not found”. The dll is installed in GAC for sure. This is for AJAX ASP.Net and apparently this has to be turned off for SharePoint 2010 which relies on .NET 3.5.