Asp.Net iframe Cookie 域 的問題!

來源:互聯網
上載者:User
Web應用A中的a.htm中有一個iframe,iframe指向Web應用B的b.aspx(含Web應用B的Cookie讀寫操作,與A應用無關) B應用相當於廣告發布系統應用,b.aspx即廣告展現頁面,A應用相當於廣告發布網站,a.htm即廣告發佈頁面

A應用部署於http://www.123.com下,B應用部署於http://www.456.com.cn下
a.htm代碼如下
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
   <div>
      <iframe src="http://www.456.com.cn/aditem/b.aspx" width=500 heigth=300  frameborder=1 scrolling=no></iframe>
   </div>
</body>
</html>
-----------------------------------------------------------------------------
b.aspx沒有人工加任何代碼
---------------------------------------
b.aspx.cs的page_load代碼如下
for(int i=0;i<this.Request.Cookies.Count;i++){
   if(this.Request.Cookies[i].HasKeys==true&&this.Request.Cookies[i].Name=="TCL"){
      for(int j=0;j<this.Request.Cookies[i].Values.Count;j++){
         string sname=this.Request.Cookies[i].Name;
         string sitem=this.Request.Cookies[i].Values.AllKeys[j];
         string svalue=this.Request.Cookies[i].Values[j];
         this.Response.Cookies[sname][sitem]=svalue;
      }
      break;
   }
}
this.Response.Cookies["TCL"]["ITEM"+DateTime.Now.ToString("yyyyMMddHHmmss")]=DateTime.Now.ToString("yyyyMMddHHmmss");
if(CADProvider.CADProvider.Domain!=null&&CADProvider.CADProvider.Domain!=""){
   this.Response.Cookies["TCL"].Domain=CADProvider.CADProvider.Domain;
}
this.Response.Cookies["TCL"].Path="/aditem";
this.Response.Cookies["TCL"].Expires=DateTime.Now.AddHours(1);
-----------------------------------------------------------------------------
其中CADProvider.CADProvider.Domain為設定檔中讀取的Cookie的網域名稱
目的是開啟http://www.123.com/a.htm時,http://www.456.com.cn/aditem/b.aspx會讀寫Cookie,都是www.456.com.cn/aditem/b.aspx自己用的,和www.123.com沒有關係。
真是不明白了 CADProvider.CADProvider.Domain 配置為 www.456.com.cn / .456.com.cn / 456.com.cn / www.123.com / 123.com,Path設定和不設定 b.aspx都不能讀寫Cookie啊!
單獨調用 http://www.456.com.cn/aditem/b.aspx ,Cookie讀寫都是正常的!
------------------------------
去請教了高人,說這是跨域寫Cookie,雖然可以通過頁面跳轉的方式來寫Cookie,但我的應用程式環境不允許進行頁面跳轉方式來寫Cookie。
微軟真是的,iframe中自己寫自己的Cookie,又不訪問其他域的Cookie,這也有安全隱患?

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.