How to debug custom application pages in Sharepoint

To debug your custom application pages located in layouts folder, perform the following steps:

  1. In IIS, select your web application and from context menu, select Open. It will display the directory in windows explorer
  2. Edit Web.config in any text editor (e.g. Notepad)
  3. In web.config, search for compilation node like “<compilation batch=”
  4. To enable debugging, update the node as follows
    • Set batch=false
    • Set debug=true
  5. After update, your compilation node will become <!– /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:””; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:”Times New Roman”; mso-fareast-font-family:”Times New Roman”;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.Section1 {page:Section1;} –>

    <compilation batch=false debug=false>

  6. Launch Internet Explorer and browse your custom application page
  7. Now, launch Visual Studio and open your Custom Application Page from layouts directory
  8. Go to Debug->Attach To Process and attach to w3wp.exe
  9. attachtoprocess1
    attachtoprocess2

  10. Add break points as necessary.
  11. In Internet Explorer, refresh your page and bingo! you can debug your custom application page now.
Share

5 thoughts on “How to debug custom application pages in Sharepoint”

Comments are closed.