If you're building a new Web Part, in order to debug it,
1)You have to manually attach the Visual Studio debugger to the W3SVC.EXE process
2)Select Debug -> Attached to Process...
3)And then selecting one or more instances of the W3SVC.EXE process, and click Attach.
Some times this throws error message saying "Cannot load symbols" and our code lines are not hit by debugger.
Then in that case we have to point the debugger to symbols in following way.
1)Copy the PDB file we have with our application and move to put the debugging symbols in the same location as the assembly.
2)Start » Run then type in run command prompt "%systemroot%\assembly\gac "
This will open the GAC folder. Now select your file of choice which is in following format
[assembly file name -.DLL extention]\[assembly version in format of #.#.#.#]__[assembly public key token].
3)Copy the PDB file to that folder and then attach the debugger.