SharePoint 2013: Custom Error Pages


You may also be interested in: Critical Path Training


 

Editor’s note: Contributor Gokan Ozcifci is a SharePoint Consultant at Vision IT Group. Follow him @gokanozcifci

A great change in the new version of SharePoint Server is that there is a support of Custom HTTP 404 Error Pages. In this post we will take a look how to create a new 404 page.

All Publishing sites contain a default a 404 Error page “PageNotFoundError.aspx” page which is added to the App "Pages Library" therefore connect to a Publishing site. If you don’t have any publishing sites, check the image, to see how to create one.

2013-01-20-CustomError-01.png

After you create your site, you can go to your site’s contents and check under your App "Page library" for the current and out-of-the-box PageNotFoundError.aspx

2013-01-20-CustomError-02.png

To allow users to create a new custom Error page, Publishing Sites now contain a new Content Type “Error Page“. This Content type Inherits from “Page” Content type and has a typical layout of a Page Not found. To find this Content Type, Navigate to Site Settings -> Content Types -> Error Page.

2013-01-20-CustomError-03.png

You can modify this page to add some text or images. But we want to create a new custom Error Page. For this go back to your App "Page Library" and create a new document "Error Page"

2013-01-20-CustomError-04.png

Provide some information and be sure that you select an (Error Page) Error.

Title: Custom Error Page
Description: Custom Error Page gknzcfc.net
URL Name: Custom-Error-Page

2013-01-20-CustomError-05.png

You will now see your new page appearing under your App.

2013-01-20-CustomError-06.png

Check out, and make modifications to your page. I’m a huge lover of Doctor House, so I added a picture of him to make clear that the page was not found :^)

2013-01-20-CustomError-07.png

I received a question from Isha [MVP SharePoint] asking about "how we could set a custom error page as default

2013-01-20-CustomError-08.png

The answer is quite simple:

2013-01-20-CustomError-09.pngRename "your" custom error page to PageNotFoundError.aspx and delete the out-of-the-box

2013-01-20-CustomError-09.pngUse the FileNotFoundUrl via Visual Studio. Get the SPSite server relative URL or absolute URL to the file not found page. This value is used as a redirect URL for an HTTP request where the resource cannot be found.

But, what if you do not want to create a new one, but only want to modify?

We’ve all seen it; the SharePoint 20xx error message is something terribly not "user-friendly".

Now, I like the Correlation ID and being able to track the error down. However, in real world scenarios it’s unlikely that our users will leave this screen up and copy/paste to our support group. Wouldn’t it be nice to have a warmer error message with our company logo and a link that will ask the user to send the error details?

2013-01-20-CustomError-09.pngConnect your Application Server and navigate to 15>TEMPLATE>LAYOUTS

2013-01-20-CustomError-10.png

2013-01-20-CustomError-09.pngLocate and copy the error.aspx file. Never never never ever touch the system files. Make copies and use those and if something goes wrong you can always come back.

2013-01-20-CustomError-11.png

2013-01-20-CustomError-09.pngOpen the error.aspx with notepad and paste the following items to get a LOGO and a HYPERLINK:

Logo


<asp:Panel id="ErrorPageTitlePanel" runat="server" tabindex="0">
<img src="vcg.jpg"/><br/><br/>Vision Consulting Group:</span>
< /asp:Panel>

Ticket Link


<asp:Panel id="PlaceHolderPageTitleInTitleArea" runat="server"><p>
<a href="mailto:info@gknzcfc.net?subject=New SharePoint Incident&body=<Please provide a short description and paste error >">Log SharePoint Support Ticket</a></p></asp:Panel> 

2013-01-20-CustomError-09.pngYou can choose where you want to copy those elements (think logic). When finished, you can save and try to get a Correlation ID. If everything went right, you should receive an error screen like this:

2013-01-20-CustomError-12.png

2013-01-20-CustomError-09.pngAnd when somebody clicks on "Log SharePoint Support Ticket" Outlook will open a new message and the user has only to enter some information and click "send"…

2013-01-20-CustomError-13.png

Happy Configuring,
G.