https和http 調用過程當中請求頭 referrer 獲取不到的問題

HTTP協議規定:
    
    
    
    
    
Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

解決辦法:
一、表單添加一個字段 referrer ,若是頭部沒有Referer,則獲取表單的這個字段,
     添加js:
     
     
     
     
     
<input id="referrer" type="hidden" name="referrer" /> <script type="text/javascript"> document.getElementById("referrer").value = window.location.href </script>

二、後臺:
     
     
     
     
     
  1. }
string urlReferrer = ""; if (Request.UrlReferrer == null) { urlReferrer = Request["referrer"]; else { urlReferrer = Request.UrlReferrer.AbsoluteUri; }





相關文章
相關標籤/搜索