2012-07-30 74 views
-1

我想動態地將https設置爲我的網址。我只想在我的登錄和籃子aspx文件上使用https。這裏是我的代碼:動態地向網址添加https

在HTML文件:

<span runat="server" id="spnGiris"><a href="<%#GetDomain(true)%>/Login.aspx">Personel 
       Girişi&nbsp;&nbsp;</a></span> 
<a href="<%#GetDomain(false)%>/Default.aspx?q=e">Çıkış</a></span> 

在服務器端:

public string GetDomain(bool https) 
    { 
     string protocol = https ? "https" : "http"; 
     string s = Request.Url.Host.ToLower(); 
     if (s.Equals("localhost")) 
      return protocol + "://localhost:14553"; 
     return protocol + "://" + ConfigurationManager.AppSettings["domainName"]; 
    } 

我把斷點GetDomain和HTTPS是在login.aspx的始終爲false。但在籃子.aspx一切都很好。 你有什麼建議嗎?

+0

您的代碼正在清除調用GetDomain(true),您將不得不提供有關GetDomain(true)未被調用的更多信息。 – 2012-07-30 19:24:29

回答

0

我改變了<%#GetDomain(true)%>與<%= GetDomain(true)%>並解析。