There's no way inside of Visual Studio to convert a web application project to a class library.
However, this is pretty easy done using your favourite text editor of choice by editing the .csproj-file changing two lines.
If you're not totally confident with what you're about to do, make sure you start with making a backup!
Solution originally found here.