Sunday, January 23, 2011

Show friendly error in SharePoint

Sometime, i dont know why my webpart (or site/page) happens error, event thought i turned off the CustomError tag in Web.Config

<CustomError mode="Off"/>

The default vallue of Mode is "ON", that means, SharePoint will show the error page liek this:

We've never known what about this error and also in the code there are any functions/methods give this issue. So, to let SharePoint show friendly the error and the stack trace of this error, we must change some values/attribute of tag in web.config.

1) Set Mode of <customerror> is Off

<CustomError mode="Off"/>

2) Find the tag <combilation> and change the value of debug is True

<compilation batch="false" debug="true">

3) In <SharePoint> tag, change the attributes of <SafeMode> to be:

<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="true">

Remember that doing reset IIS before press F5.

Now you can see your error as details and it's very easy to fix.

No comments: