Is there a way to set custom headers on a site collection ?

I'm trying to resolve issues with compatibility mode and an http header is needed


After going through a lot of MSDN docs and wasting lots of time on this the verdict is: Response Headers CAN NOT BE SET or added on Office 365 (Sharepoint Online, talk about Brand cannibalization)

The initial issue I was having however I was able to fix using the <meta> tag (which wasn't working initially, and it's quite visible to see why in the code pasted below) by actually making sure that:

<meta http-equiv="X-UA-Compatible" content="IE=EDGE"/>

doesn't have anything above it other than <Doctype and <html

So here's what we had initially (this was used by the front end guys for foundation framework)

<!DOCTYPE html>
<!--[if IE 8]>               
<html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]>
<!--> <html class="no-js" lang="en"> <!--<![endif]-->
        <meta charset="utf-8" />

Here's what it is now:

<!DOCTYPE html>
        <meta http-equiv="X-UA-Compatible" content="IE=EDGE"/>

And then the IE check tags go between </head> ... <body>

UPDATE: Within a webpart, using this.Context.Response.Headers.Set("some", "more"); throws a "PlatformNotSupportedException ... This operation requires IIS integrated pipeline mode"

Using this.Context.Response.AddHeader("some", "more"); does not throw the Exception but is not adding any headers to the response. :(

  • As you've noted, adding a header isn't supported. If you've found a bug with compatibility mode you can file it with the product team. It seems you've found a solution though so all is good. In general, if a solution requires a header set then your solution isn't compatible and you must find a supported method to do what you want. – James Love Jun 2 '13 at 17:10

With SharePoint Online you have no direct access to the web.config files, IIS, or to deploy custom code solutions. So, you won't be able to add the Http Header in any of those fashions.

You can, however, specify the the compatibility mode in the master page. Using SharePoint Designer (2010 or 2013 depending on what version of SharePoint you are hosted on), edit the master page you are using and modify the compatibility mode meta tag:

<meta http-equiv="X-UA-Compatible" content="IE=10"/>

If you are new to master pages, see http://office.microsoft.com/en-us/sharepoint-designer-help/introduction-to-sharepoint-master-pages-HA102019628.aspx. This is a good introduction from Microsoft.

If you need more information on the meta tag and its usage, see http://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx.

  • Already tried the meta tag and that didn't work when: Tools -> Compatibility View Settings -> Display all websites in Compatibility View, was selected. What did work however was replicating the exact same page in php and setting the response header. Worked like a charm. So we're basically screwed. – haknick May 31 '13 at 3:54
  • So going back to the question, would it be possible to add a custom web-part that gets called in the master page ? – haknick May 31 '13 at 4:01
  • I already have a dozen visual web-parts working on inner web-part pages but not sure if I can include them in the master page – haknick May 31 '13 at 4:02
  • 1
    If you can deploy custom solutions to your SharePoint Online instance, you could use an AdditionalPageHead Delegate Control to get the code on every page. I have some blog posts about creating AdditionalPageHead controls: sharepointjohn.com/… – John Chapman May 31 '13 at 18:02
  • 1
    So how would the AdditionalPageHead control help with setting an HTTP response header ? – haknick May 31 '13 at 19:25

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.