Getting SharePoint to Tell You More about that "Unexpected Error"
If you're developing for SharePoint, you've undoubtedly encountered the oh-so-vague Unexpected Error. This blog will show you what changes need to be made to the web.config to make SharePoint tell you more.
Which Web.Config?
To find out which web config you should modify depends on your setup. Chances are, you can simply modify the one located in the root of the virtual directory associated with the web application that's causing the problems. To get there, follow these steps:
- Open Windows Explorer.
- Navigate to C:\inetpub\wwwroot\wss\Virtual Directories\
- Here are all the web applications you have in IIS. Choose the one that's name corresponds to the port number of the web app you're looking for.
- Open said web.config.
The Changes
There are four in total, and here they are:
- Search for the word "callstack". The line will look like this:
<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="true">
Set the value of the CallStack attribute to true.
- Search for the word "customerrors". That line looks like this:
<customErrors mode="On" />
Set the value of the mode attribute to Off or RemoteOnly. Hopefully, you are doing all of this debugging on a test server so turning custom errors off entirely shouldn't be a big deal.
- Search for the word "batch". This last line looks like this:
<compilation batch="false" debug="false">
Set the value of the batch attribute and debug attribute to true.
Next
Now, go back to your page and hit refresh. You will see a much better error message and hopefully a stack trace pointing to your problem. If the Unexpected Error message didn't change, make sure you're web.config changes took hold by either resetting IIS entirely or recycling your application pool.