Monday, January 14, 2008

Reveal Unknown Error on Sharepoint 2007 pages

How often you have encountered the infamous Unknown Error on Sharepoint 2007 pages. If you are a Sharepoint developer, chances are that innumerable times :)

However, if you are also seasoned ASP.NET developer as well, you also know the trick behind it to reveal them., which I am going to give it here.

The trick is that ASP.NET Framework wants to show the real error message, but its the sharepoint which abstracts the message from the user. This is good for production systems since those cryptic error message may not be user friendly. Or revealing those full stack trace could cause potential security concerns.

But for an experienced developer, this is almost must to turn them off. This is achieved by turning off custom errors in web.config

Find the web.config for the site you normally use as your development site. Locate this tag

<SafeMode ... CallStack="false" ...> and change it to CallStack="true"
Set <customErrors mode="On" /> to mode="Off"
Set <compilation batch="false" debug="false"> to <compilation batch="true" debug="true">

Now you will get the full stack trace as soon as the error is raised.


Anonymous said...

that is the best Sharepoint Tips i have seen for months, so simple and yet saving me sooooo much time... "God bless your pink cotton socks" :)

Anonymous said...

nice post

Anonymous said...

Would be an even better post if you could give the newbies like me a slight clue of where to find that magic file...

Anonymous said...

If you don't know where web.config is, you probably shouldn't be making the changes. But anyway, for future reference, here is the default location: c:\inetpub\wwwroot

for a Windows web server.

Cathy Walker said...

Really??! Is this for real? Be trying this out once I got home. I'm taking Learning Microsoft Sharepoint 2007 and we haven't discussed any of this unknown error.