An unexpected error occurred! Debugging SharePoint WebParts – Tips Reminder!

Every once in a while, I am debugging a webpart on SharePoint and all of a sudden, the page broke. The error message on the page is "An unexpected error occurred" which tells me nothing other than the fact that it's an error.

To turn the not-at-all-helpful error message into a meaningful one (meaningful for the development environment), 2 easy changes in the web.config file:

<customErrors mode="Off" /><!– change the mode from “On” to “Off” –> 

 

<!– change the CallStack from “false” to “true”–><SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" ..

Another error message sometimes I get is "one or more of your webparts is causing problem. Close the webpart(s) in the maintenance page". This is better than the last error message as I can at least close/delete the trouble making webpart(s).

Today, I need to do webpart debugging and I want to have access to the maintenance page. How? Short and easy to remember, just append "?contents=1" to the page URL.

For example,

http://servername:portnumber/sites/abc/pages/default.aspx?contents=1

 

Leave a Reply