Tuesday, August 24, 2010

How to enable SharePoint to handle the forbidden files ?

We tried to store files which has the (.rules) extension in document library, once we added all these files to the document repository,we tried to download these files by clicking on it. It ended up in an error message stating.

This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden.
The extension '.rules' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /Financial Documents/TestRulesSet.rules
But the Send to->"Download a copy"  option works as expected. When we use this method we are asking the OOB download.aspx page to download the content for us.

 After re-collecting the basics of SPHttpHandler which handles all the SharePoint requests. This handler is forbidding this specifying file type. so the solution is to
Add a http handler before SPHttpHandler which serves this file type as expected

 Open windows explorer , navigate to the virtual directory and open web.config with your favorite text editor

 Find section and the following segment below after the remove block, so after adding the httpHandlers section will look like below

 <remove verb="GET,HEAD,POST" path="*" />
<add verb="*" path="*.rules" type="System.Web.StaticFileHandler" />
<add verb="GET,HEAD,POST" path="*" type="Microsoft.SharePoint.ApplicationRuntime.SPHttpHandler...

 Do an IISReset

Warning : Do understand the risk of exposing these forbidden files using StaticFileHandler

Following is the list of Http handlers which takes care of the frequently used ASP.NET file types
  • trace.axd - System.Web.Handlers.TraceHandler
  • aspx - System.Web.UI.PageHandlerFactory
  • ashx - System.Web.UI.SimpleHandlerFactory
  • asmx - System.Web.Services.Protocols.WebServiceHandlerFactory
  • rem - System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory
  • soap - System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory
  • asax - System.Web.HttpForbiddenHandler
  • ascx - System.Web.HttpForbiddenHandler
  • All sharepoint request - Microsoft.SharePoint.ApplicationRuntime.SPHttpHandler
  • Reserved.ReportViewerWebControl.axd -Microsoft.Reporting.WebForms.HttpHandler


Anonymous said...


I am also facing same issue in SP 2010. Please advise me how can I implement into 2010.

Aravind said...

This solution should ideally work for SharePoint 2010 too