Cookie not being sent in iframe in IE9

前端 未结 4 388
感情败类
感情败类 2021-01-31 17:50

First of all, I\'ve did some research before posting this question, so I know about the P3P Policy and the MSDN article about it. From what I understand, this policy mostly (if

4条回答
  •  无人及你
    2021-01-31 18:16

    If anyone is trying to solve this for a .NET Application

    Add a P3P header as Carlos mentioned

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

    Edit: Even better, if you want to put this in Controller, simply add the following attribute

    public class IEP3PHeaderAttribute : FilterAttribute, IResultFilter
    {
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // check if the user is using a IE based browser, add a p3p header if true and hasn't already been added
            if (HttpContext.Current.Request.Browser.Browser.ToUpper().Contains("IE"))
            {
                if (System.Web.HttpContext.Current.Response.Headers["p3p"] == null)
                {
                    HttpContext.Current.Response.AddHeader("p3p", "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");    
                }
            }
        }
    
        public void OnResultExecuted(ResultExecutedContext filterContext)
        {
        }
    }
    

    and then in your controller, e.g. HomeController

    [IEP3PHeader]
    public class HomeController
    {
       public ActionResult DoSomething() {};
       public ActionResult DoSomethingElse() {};
    } 
    

提交回复
热议问题