1

We've been looking at enabling the Permissive File Handling in Central Admin of our SharePoint 2010 on an intranet site collection. However, we're wondering if we can allow specific file types to be rendered: In our case, we need users to be able to upload and display *.HTML files in the iframe web part. Is this possible or is it all-or-nothing?

Unless we set it to Permissive, SharePoint offers to let us download the HTML file rather than rendering it in the iframe.

Thanks.

2 Answers 2

3

Wrote a blog on this some time back:

http://vrdmn.blogspot.in/2012/06/use-html-pages-in-sharepoint-2010-html.html

So basically there are two modes for file handling in SharePoint 2010. "Strict" and "Permissive". Strict mode entails that only the trusted filetypes in the web application are opened in the browser. For all the rest of the filetypes the response will include a "X-Download-Options: noopen" header. This header will basically instruct the browser not to open the file inline. When the mode is Permissive, no such restriction will be placed on the files. If a file lives inside SharePoint, then it will be displayed inline by the browser.

You can create a hybrid approach by keeping the Browser file handling mode as "Strict" and using the SPWebApplication.AllowedInlineDownloadedMimeTypes property of the web application to specify which file types are trusted in your web application.

4
  • Please try to provide a little summary, backed with link to your blog. Jul 8, 2012 at 22:21
  • 1
    It's an interesting trick to use the *.aspx on the *.html file; it fools SharePoint into rendering the page without using Permissive file handling.
    – Alex C
    Jul 9, 2012 at 5:47
  • 1
    @ AlexC Glad I could help @FalakMahmood No problem. Updated the comment. Jul 9, 2012 at 6:00
  • 1
    Great @VardhamanDeshpande Jul 9, 2012 at 6:47
2

Use AllowedInlineDownloadedMimeTypes

Here is code for a single web app in PowerShell

$webApp = Get-SPWebApplication http://intranet.contoso.com
$webApp.AllowedInlineDownloadedMimeTypes.Add("text/html")
$webApp.Update()

Or for all in C#

SPFarm farm = SPFarm.Local;
SPWebService service = farm.Services.GetValue<SPWebService>("");

foreach (SPWebApplication webApp in service.WebApplications)
{
    webApp.AllowedInlineDownloadedMimeTypes.Add("text/html")
    webApp.Update()
}
2
  • Thanks, Per Jakobsen. Is it possible to do this in server-side code rather than PowerShell?
    – Alex C
    Jul 9, 2012 at 6:48
  • 1
    Yes. I've added code for enabling it on all WebApps using c# in answer. But often you'll put it in a feature receiver of a WebApp scoped feature in that case you get the webApp from the Parent property Jul 9, 2012 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.