21 October 2015

Accessing Custom SharePoint pages - 404 : not found error

Recently we deployed some custom SharePoint pages under 15 hive folder in SharePoint via WSP deployment.

When we tried to access them, they were not accessible and we were getting 404 not found error.

We were trying to access the custom SharePoint pages via following URL -

http://<sharepoint-web-application>/_layouts/15/<Custom_Folder>/<Custom_Page>.aspx

Finally after lot of headache we realized that we were doing two mistakes -
  1. SharePoint custom pages cannot be accessed directly without giving reference to site collection.
  2. If you want to access directly without giving reference to any site collection, then there should be a root site collection ("/") under the SharePoint web application.
In our case, both the conditions were not satisfied. The solution for the problem is - 

Solution 1

Create a root site collection ("/") under the web-application. Once that is created, we can access the custom page using following URL - 


http://<sharepoint-web-application>/_layouts/15/<Custom_Folder>/<Custom_Page>.aspx

This works now because "/" after "<sharepoint-web-application>" is interpreted by SharePoint as root site collection which satisfies the condition that SharePoint custom pages should be accessed by giving reference to site collection.

Solution 2

If you cannot created root site collection or don't have one created, then access the custom pages using following URL - 

http://<sharepoint-web-application>/<site-collection>/_layouts/15/<Custom_Folder>/<Custom_Page>.aspx

Simple thing but sometimes during development and troubleshooting, we miss these basic points and end up spending lot of time in fixing them.



No comments: