There are a few subscription-only services that allow you to check for mobile browsers so that you can service optimized content, but you can also download this free file from CodePlex which claims to do the same.
I haven't tried it yet, but might be worth a look:
http://mdbf.codeplex.com/wikipage?title=Getting%20Started&referringTitle=Home