An unexpected error has occurred

This message is the biggest pain-in-the-butt for SharePoint developers – I’m sure you’ve seen it on more than one occasion.

Thanks for nothing SharePoint !!

image

Working out WHAT error has occurred can be annoying and frustrating !!

Bear in mind that SharePoint itself is (to overly simplify matters) – just an ASP.NET web application, complete with ASPX pages, ASCX controls, and web.config files – and a big, scary SQL Server database behind the scenes.

It follows that you can use the same debugging methods when dealing with SharePoint – as for any other ASP.NET application.

The scenario I’m having problems with (in this example) is that a master page for a content publishing site is misbehaving, and giving me the “unexpected error”.

When using other master pages, there is no error – but “my” master page causes a problem.

There’s nothing listed in the Event Viewer – nothing relating to the specific site or page/s.

So – here’s the trick :

  • Find the web.config for the specific SharePoint site
    • The default location is as follows – with one folder per “port” :

C:InetpubwwwrootwssVirtualDirectories

  • Open the web.config file – using Visual Studio or Notepad
  • Change the following settings

<SafeMode CallStack=”true“>

image

  • And…

<customErrors mode=”Off” />

image

  • Close and save the file
  • IMPORTANT – do an IISRESET, to reload the updated settings
  • Refresh/re-load the page (CTRL-F5)
  • You should get a more helpful ASP.NET stack trace.

In my case, I’d broken the master page by removing a content placeholder – or, as the MythBusters would say – “well THERE’s your problem !”

image


On the topic of Master Pages, and SharePoint Publishing sites, Heather Solomon has a number of awesome resources for SharePoint “publishing” :

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s