SharePoint Display custom error Message in Errorpage

Normally the SharePoint errors are filled with messages that no user will understand followed by a correlation id. Well, the user knows there is an error, but what should he do next? It would be nice to give him some advice like try to refresh the page or anything. Therefore the SPUtility provides a nice solution. With TransferToErrorPage you can simply bring your own text into an error message. This is useful if you develop some features or custom pages or anything custom.



SPUtility.TransferToErrorPage(string.Format("Error loading List Form Page: {0}\r\n\r\nStack Trace:\r\n{1}", ex.Message, ex.StackTrace));

//OR

SPUtility.TransferToErrorPage("Dear User, there was an error. We apologize for that. Please refresh the page and try again.");


The result of the error message is like this:

Errorrpage

Looks better right?

But keep in mind: In this case there will be nothing added to ULS no logging entry is made. So you have to add it by yourself.

..:: I LIKE SHAREPOINT ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.