8/27/2012

Hostgator email can't send to hosted domain

這是個奇怪的症狀, 在 Hostgator 上, 我自己有個發信的 Module, 可以發信給任何 Domain, 唯獨自己 Hosted 的 Domain 不行.

幾經測試, 就是不 work, 最後聯絡 Hostgator Tech Support, 才得到解決.

狀況是這樣的, 當我們在 Hostgator 上 Add Domain 時, 系統會 Default 把 Hosted Domain 加到 Mail Server 中. 即使我們不使用 Hostgator 的 Mail  Server, 但是當我們的發信 module send 給 hosted domain 的 account 時, 就會自己跑到 Local Server 上, 永遠也發布出去.

解決辦法, 就是 Contact Hostgator, 請他們把 domain name 從 Local Mail Server 中移除, 不然永遠沒轍.

8/20/2012

Hostgator Session Timeout 太快的問題

最近在 Hostgator 上碰到個問題, User Login 進去後, 很快就 Session timeout, 被踢出來, 不明其原因. 又加上是 Shared Web Hosting, 根本沒有辦法去改到 IIS 的設定.

有一說是因為 Application Pool 不定時回收, Default 設定是五分鐘, 當 Application Pool 回收時, 會自動把所有的 Session Reset, 所以就 Timeout 掉了.

問題來了, 我又不能去改 IIS 設定, 那該如何處理? 

後來找到一篇文章, 上面提到的方式, 可以解決我的問題 ==> 就是它

他的 Solution 就是去 Web.config 裡面加上一組 machinekey, 就解決了.

這裡有個 machinekey generator, 用它產生 Machine Key 然後貼到 Web.config 中的 <System.web> Section 中, 在 Hostgator 被 Timeout 掉的問題就解決了!


8/15/2012

C# : How to Identify a Nullable Type

在 .Net Coding 中, 我常會用 class destructor 把一些 Resource Release 掉.

因為 .Net 本身有 Garbage Collection 的功能, 所以只要把已經 Allocate Resources 的 Object 指定為 Null 或是 Empty, 原來 Allocate 的 Resources 就變成無主孤兒,  將會被 Garbage Collection 回收.

問題來了, 不是每個 Type 都是 Nullable, 要如何判斷 Nullable, MS 在 MSDN 中提供了方法, 裡面還有些 Trick.

請參考: http://msdn.microsoft.com/en-us/library/ms366789.aspx

Use the following code to determine whether a Type object represents a Nullable type. Remember that this code always returns false if the Type object was returned from a call to GetType, as explained earlier in this topic.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) {…}

8/08/2012

ProFTPD can not be connected via Filezilla

最近在 Ubuntu Server 上安裝了 proFTPD, 準備給公司 HKG 同事將來可以交換資料, 但是發現一旦用了 FileZilla 的 FTP Client 來連線, 就會出現
Failed to retrieve directory listing.
的錯誤訊息. 而且改用其他的 FTP Client 來連線, 就可以使用, 相當奇怪.

經過網路 Search, 找到 Solution, 在 ProFTPD 的 configure File 中, 加入下列片段即可

<ifmodule mod_facts.c="mod_facts.c">
FactsAdvertise off
</ifmodule>