牛腩新聞發布系統之擷取IP,牛腩新聞發布系統ip

來源:互聯網
上載者:User

牛腩新聞發布系統之擷取IP,牛腩新聞發布系統ip

牛腩新聞發布進行中,面對前17集的後台製作,真的有一種相見恨晚的感覺,不得不佩服牛老師(雖然他不姓牛)對於一個系統的宏觀把握。接著來到了HTML的前台設計,牛老師又一次將我震撼,調代碼的時間基本不會超過5秒。孰能生巧,一種船到橋頭自然直的感覺。

最後來到了前台和後台整合的部分,擷取訪問頁IP的時候,出現了這麼一個錯誤。

大家看到沒有,在頁面的左上方本應該出現的是我的本機ip地址,但是出現了::1這樣的錯誤i

首先找到了錯誤的原因:由於我的系統是win764位作業系統,採用的是ipv6。

先來看看My Code吧。

<span style="font-size:18px;"><strong>//添加進資料數            string com_content = txtcomment.Text;            string newsid = Request.QueryString["newsid"];            string userIp = Request.ServerVariables["REMOTE_ADDR"];</strong></span>
關於上面的代碼重要的是 string userIp = Request.ServerVariables["REMOTE_ADDR"];這段代碼。但是我查了好多的方法就是無法解決不顯示::1讓它顯示本地ip的方法,所以我想出了這麼一個辦法。

<span style="font-size:18px;"><strong>    //添加進資料數            string com_content = txtcomment.Text;            string newsid = Request.QueryString["newsid"];            string userIp = Request.ServerVariables["REMOTE_ADDR"];            if (userIp == "::1")            {                userIp = "192.168.24.100";            } </strong></span>

最後顯示:


如果大家有更好的方法,可以和我交流學習。

最後

Request.ServerVariables[] 讀解
Request.ServerVariables["Url"] 
返回伺服器位址


Request.ServerVariables["Path_Info"] 
用戶端提供的路徑資訊


Request.ServerVariables["Appl_Physical_Path"] 
與應用程式中繼資料庫路徑相應的實體路徑


Request.ServerVariables["Path_Translated"] 
通過由虛擬至物理的映射後得到的路徑


Request.ServerVariables["Script_Name"] 
執行指令碼的名稱


Request.ServerVariables["Query_String"] 
查詢字串內容


Request.ServerVariables["Http_Referer"] 
請求的字串內容


Request.ServerVariables["Server_Port"] 
接受請求的伺服器連接埠號碼


Request.ServerVariables["Remote_Addr"] 
發出請求的遠程主機的IP地址


Request.ServerVariables["Remote_Host"] 
發出請求的遠程主機名稱


Request.ServerVariables["Local_Addr"] 
返回接受請求的伺服器位址


Request.ServerVariables["Http_Host"] 
返回伺服器位址


Request.ServerVariables["Server_Name"] 
伺服器的主機名稱、DNS地址或IP地址


Request.ServerVariables["Request_Method"] 
提出請求的方法比如GET、HEAD、POST等等


Request.ServerVariables["Server_Port_Secure"]
如果接受請求的伺服器連接埠為安全連接埠時,則為1,否則為0


Request.ServerVariables["Server_Protocol"]
伺服器使用的協議的名稱和版本


Request.ServerVariables["Server_Software"]
應答請求並運行網關的伺服器軟體的名稱和版本


Request.ServerVariables["All_Http"]
用戶端發送的所有HTTP標題,首碼HTTP_


Request.ServerVariables["All_Raw"]
用戶端發送的所有HTTP標題,其結果和用戶端發送時一樣,沒有首碼HTTP_


Request.ServerVariables["Appl_MD_Path"]
應用程式的中繼資料庫路徑


Request.ServerVariables["Content_Length"]
用戶端發出內容的長度


Request.ServerVariables["Https"]
如果請求穿過安全通道(SSL),則返回ON如果請求來自非安全通道,則返回OFF


Request.ServerVariables["Instance_ID"]
IIS執行個體的ID號


Request.ServerVariables["Instance_Meta_Path"]
響應請求的IIS執行個體的中繼資料庫路徑


Request.ServerVariables["Http_Accept_Encoding"]
返回內容如:gzip,deflate


Request.ServerVariables["Http_Accept_Language"]
返回內容如:en-us


Request.ServerVariables["Http_Connection"]
返回內容:Keep-Alive


Request.ServerVariables["Http_Cookie"]
返回內容:Cookie的值


Request.ServerVariables["Http_User_Agent"]
返回內容:Mozilla/4.0[compatible;MSIE6.0;WindowsNT5.1;SV1]


Request.ServerVariables["Https_Keysize"]
安全通訊端層串連關鍵字的位元,如128


Request.ServerVariables["Https_Secretkeysize"]
伺服器驗證私人關鍵字的位元如1024


Request.ServerVariables["Https_Server_Issuer"]
伺服器憑證的發行者欄位


Request.ServerVariables["Https_Server_Subject"]
伺服器憑證的主題欄位


Request.ServerVariables["Auth_Password"]
當使用基本驗證模式時,客戶在密碼對話方塊中輸入的密碼


Request.ServerVariables["Auth_Type"]
是使用者訪問受保護的指令碼時,伺服器用於檢驗使用者的驗證方法


Request.ServerVariables["Auth_User"]
代證的使用者名稱


Request.ServerVariables["Cert_Cookie"]
唯一的客戶認證ID號


Request.ServerVariables["Cert_Flag"]
客戶認證標誌,如有用戶端認證,則bit0為0如果用戶端認證驗證無效,bit1被設定為1


Request.ServerVariables["Cert_Issuer"]
使用者認證中的發行者欄位


Request.ServerVariables["Cert_Keysize"]
安全通訊端層串連關鍵字的位元,如128


Request.ServerVariables["Cert_Secretkeysize"]
伺服器驗證私人關鍵字的位元如1024


Request.ServerVariables["Cert_Serialnumber"]
客戶認證的序號欄位


Request.ServerVariables["Cert_Server_Issuer"]
伺服器憑證的發行者欄位


Request.ServerVariables["Cert_Server_Subject"]
伺服器憑證的主題欄位


Request.ServerVariables["Cert_Subject"]
用戶端認證的主題欄位


Request.ServerVariables["Content_Type"]
客戶發送的form內容或HTTPPUT的資料類型

這算是一個積累的過程吧,網頁製作的道路才剛剛開始。。。。。


牛腩新聞發布系統怎安裝 我安裝來老師出錯 助下,最好詳細點

其實就是把一個固定網址的HTML源碼弄下來,然後用Regex把裡面的新聞列表的內容取出來,這個技術可以去google搜尋“採集”方面的內容來看的。牛腩:
 
有誰看到過牛腩新聞發布系統視頻?

具體是什麼問題嘛??說出來才能解答呀..
static是靜態方法,其特點是不需要執行個體化,不可以調用類的非靜態成員,比如說類中定義了連接字串,如果不是static修飾的,而你又在test()靜態方法中調用,就會出錯..
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.