Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

P3P Header Info in MVC

I'm not sure where I'm suppose to put this in my Asp.net MVC website:

HttpContext.Current.Response.AppendHeader("P3P", "CP=\\\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\\\"");

I put it in the:

public static void RegisterRoutes(RouteCollection routes)
{
  HttpContext.Current.Response.AppendHeader("P3P", "CP=\\\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\\\"");
  routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  routes.MapRoute(
      "Default", // Route name
      "{controller}/{action}/{id}", // URL with parameters
      new { controller = "Account", action = "Logon", id = UrlParameter.Optional }
  );

}

But I get back

Response is not available in this context.

Anyone know where I am suppose to put this?

like image 745
ErocM Avatar asked Dec 20 '12 15:12

ErocM


1 Answers

You can put it in the web.config:

  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="P3P" value='CP="CAO PSA OUR"'/>

This way you do not need to put it in the code.

See this SO answer for details on what the value means.

like image 193
vtortola Avatar answered Sep 21 '22 19:09

vtortola