In some situations, it will be necessary to debug a web part. In order to make a WSS web part able to be debugged, the web.config of the WSS web site where you deploy your webpart to must be modified.
Open the Web.config file and modify the existing options to look like the following:
<customErrors mode=“Off” />
<compilation batch=”false” debug=”true“>
Once the web.config is modified, you can directly set breakpoint and hit F5 in a Visual Studio environment.