Using code behind really expands what you can do in SharePoint, and a lot of folks don’t even realize it’s possible. I’ve done it before while writing some custom web services and the same concepts apply. Andrew Connell wrote a great article on how to do it so I figured I’d better link to it here before I forget how to do it! Plus it doesn’t hurt to spread the word. Thanks Andrew.
Code Behind in SharePoint v3