{"id":1344,"date":"2014-10-30T12:32:50","date_gmt":"2014-10-30T11:32:50","guid":{"rendered":"http:\/\/blog.repsaj.nl\/?p=1344"},"modified":"2014-10-30T12:32:50","modified_gmt":"2014-10-30T11:32:50","slug":"sp20xx-migrating-htm-html-mht-files-to-sharepoint","status":"publish","type":"post","link":"http:\/\/blog.repsaj.nl\/index.php\/2014\/10\/sp20xx-migrating-htm-html-mht-files-to-sharepoint\/","title":{"rendered":"[SP20xx] Migrating HTM, HTML, MHT files to SharePoint"},"content":{"rendered":"<p>It seems this issue\u00a0arises in almost every migration project: <em>&#8220;Hey, we have a bunch of HTML based files which we&#8217;ve uploaded to SharePoint, but now they don&#8217;t work any more!&#8221;<\/em>. With &#8220;don&#8217;t work&#8221;, usually it\u00a0means the user is prompted to download the file instead of being able to just view it in the browser. So it&#8217;s working, but the end result is not what the end-user expects. Also, &#8220;a bunch&#8221; is usually a couple of hundred files which were exported from some legacy application a few years back and have been sitting on a file share or in SharePoint 2007 ever since.<!--more--><\/p>\n<h3>The problem<\/h3>\n<p>So first we need to understand what the problem is. I won&#8217;t go into too much detail because there are already enough blogs out there on this. There are three\u00a0things you should know about:<\/p>\n<ol>\n<li><strong>Trusted MIME types:<\/strong>\u00a0each file has a MIME type. It describes the type of file we&#8217;re dealing with. SharePoint comes with a default list of trusted MIME types which you can set via Powershell. Check out <a href=\"http:\/\/social.technet.microsoft.com\/wiki\/contents\/articles\/8073.sharepoint-browser-file-handling-deep-dive.aspx\">this blog<\/a>\u00a0on TechNet for a deep dive.<\/li>\n<li><strong>Blocked\u00a0file types:<\/strong>\u00a0the list of blocked file types is found under &#8220;Security&#8221; in Central Administration. That alone should be an indication of what it&#8217;s for: <strong>security<\/strong>. Use this list to manage the types of files a user can upload to SharePoint, based on their extension (.zip, .exe, etc.)<\/li>\n<li><strong>Browser File Handling<\/strong>. This is a setting which you can manage on web application level. It has two settings: Strict and Permissive.<\/li>\n<\/ol>\n<p>So, when wanting to use HTML files on SharePoint there are a few things you can bump into. First, the filetype might be in the blocked file types list, which means you cannot upload them at all. You might have avoided this because your files were migrated from a SP2007 site where this usually wasn&#8217;t an issue. Or your administrator added the file type to the trusted types, which they shouldn&#8217;t have done (more about that later).<\/p>\n<p>If you were able to upload, or the files were already there, the browser file handling is normally set to Strict and the HTML MIME type is not in the trusted MIME types list. That combination will trigger SharePoint to add a security header which in its turn tells your browser to\u00a0<strong>download<\/strong>\u00a0the file instead of opening it. Which is not what your users want, they want the file to be opened in their browser.<\/p>\n<p>&nbsp;<\/p>\n<h3>Solutions<\/h3>\n<p>Without too much detail about the why, let&#8217;s skip to the solution part. The bad news: you should <span style=\"text-decoration: underline;\">not<\/span> allow people to view HTML based files straight from SharePoint in their browser. The reason is twofold: the security risk being the most important. Users can download all kinds of weird pages and scripts from the internet and host them on SharePoint. Colleagues might click these pages and run scripts they should not run. Be warned: a JavaScript file is perfectly capable of asking the user for credentials and sending those to some remote server. Especially when it is running in IE&#8217;s Intranet zone which has low security by default. The second reason is for companies who are thinking about moving to the cloud. Note that Office 365 and other SharePoint PaaS services usually do not allow you to host these files. So you&#8217;re creating migration issues for yourself when you would allow it on-prem.<\/p>\n<p>The good news: there are some things you can offer your users to acheive the same result.<\/p>\n<ol>\n<li><strong>SharePoint pages<\/strong>: for plain HTML content, it&#8217;s perfectly doable to create some pages in SharePoint and copy\/paste the contents of the files. You can do this manually, find a tool which does it for you, or custom create such a tool.\u00a0When your files are using all kinds of scripts, linked CSS files and more, this might not be the best solution though.<\/li>\n<li><strong>Host the files \/ page viewer web part:\u00a0<\/strong>although it would be my preference, you&#8217;re not forced to host the files on SharePoint. When your IT department has a webserver available (don&#8217;t use SharePoint front-end servers for this&#8230;), explore the option of hosting the files there. When hosted, you can use the page viewer web part in SharePoint to include the content in a SharePoint site. For your end-users, it will look like the content is in SharePoint when it&#8217;s not.<\/li>\n<li><strong>Office Web Applications:<\/strong> in some cases, the HTML content is being exported from Office applications. This is usually Visio, Word or\u00a0Powerpoint content. Know that you can perfectly host these types of files in SharePoint and display them in the\u00a0browser by using Office Web Applications. The Office Web Applications come with webparts which you can include on a page to display\u00a0specific Office documents on that page. The downside is that Office Web Applications require a license and starting with version 2013, a server.<\/li>\n<li><strong>Host HTML in SharePoint:<\/strong>\u00a0as a last resort, you can configure SharePoint to host the files. That includes removing .html \/ . htm \/ .mht extensions from\u00a0the blocked\u00a0file types list. Also, you need to either add the application\/html mime type to the allowed mime types, \u00a0or change the file handling of the web application to permissive (adding the mime type is the least bad option). Note that these changes wil affect\u00a0<span style=\"text-decoration: underline;\">all sites in your web application<\/span>. The blocked file types are even set at\u00a0<span style=\"text-decoration: underline;\">farm<\/span> level. I would definitely recommend\u00a0<span style=\"text-decoration: underline;\">not doing this<\/span>.<\/li>\n<\/ol>\n<p>Those are the options I normally advise my customers. There might be other good ones out there, feel free to comment. The important lesson to learn here is that the easiest way to get it to work is also the one you don&#8217;t want to use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It seems this issue\u00a0arises in almost every migration project: &#8220;Hey, we have a bunch of HTML based files which we&#8217;ve uploaded to SharePoint, but now they don&#8217;t work any more!&#8221;. With &#8220;don&#8217;t work&#8221;, usually it\u00a0means the user is prompted to download the file instead of being able to just view it in the browser. So<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[34],"tags":[7,124,39,123],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3KFR1-lG","_links":{"self":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/1344"}],"collection":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/comments?post=1344"}],"version-history":[{"count":0,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/1344\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/media?parent=1344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/categories?post=1344"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/tags?post=1344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}