Showing posts with label ASP.net. Show all posts
Showing posts with label ASP.net. Show all posts

1/09/2017

.Net Send Email Problem - net_io_connectionclosed

最近在 migrate 舊的 .net 程式到 Windows Server 上, 其中有一個 SMTP 的 Setting 造成 Email Send 不出去, 得到下列的 Error Message.

System.Net.Mail.SmtpException: net_io_connectionclosed

Program 是 .Net 2.0, Server 是 Windows

Server 2008 在這篇文章中找到 Solution.

I ran into this today and the solution is tied somehow to the IP addresses you are using to secure the SMTP virtual server.  My server has multiple IP addresses bound to the same adapter and the VS was configured to use one of them.  However, I had all of the access restrictions to allow connections only from 127.0.0.1 which is the source of the error (I believe.

So, whatever the IP address your VS is listening on OR the IP your application is configured to use, configure the following areas:
  • Access/Connection control/Only the list below/[add your server ip]
  • Access/Relay restrictions/Only the list below/[add your server ip]
  • Configure your application to utilized the server ip, not localhost or 127.0.0.1

2/14/2014

IE animation GIF freezed.

Original Link: http://weblog.west-wind.com/posts/2004/Dec/27/Animated-GIF-images-in-hidden-page-elements

我們常會在 Process 時, popup 一個會動的 icon, 表示在進行中. 這的動作常用 animation gif 來達成.

在 IE 7 以後,常常只顯示出圖片, 但是不會動.  這是 IE 已知的 Bug, 很久都沒有 Fix. 底下這段 Code 是從 Internet 上找到的, 可以 Work.

function ShowWaitDisplay()
{
   document.getElementById('MainForm').style.display='none';
   document.getElementById('WaitNote').style.display='inline';
   Img = document.getElementById('WaitImage');
   Img.style.display="inline";
   Img.src = "images/pleasewait.gif";
   window.scrollTo(0,0);
   return true;     
}

3/08/2013

How to get IPV4 from IPV6 Environment?

Reference Link: http://www.4guysfromrolla.com/articles/071807-1.aspx  

using System;
using System.Net;

public class IPNetworking
{
  public static string GetIP4Address()
  {
    string IP4Address = String.Empty;

    foreach (IPAddress IPA in Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress))
    {
      if (IPA.AddressFamily.ToString() == "InterNetwork")
      {
        IP4Address = IPA.ToString();
        break;
      }
    }

    if (IP4Address != String.Empty)
    {
      return IP4Address;
    }

    foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
    {
      if (IPA.AddressFamily.ToString() == "InterNetwork")
      {
        IP4Address = IPA.ToString();
        break;
      }
    }

    return IP4Address;
  }
}

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 中移除, 不然永遠沒轍.

4/02/2012

ASP.Net Menu Control work in Chrome

當使用 ASP.net Menu 元件, 在 Chrome 中不 work 時, 要在程式中加入下列這段 Code.


protected void Page_PreInit(object sender, EventArgs e) 
{
             // This is necessary because Safari and Chrome browsers don't display the Menu 

                control correctly.
             // All webpages displaying an ASP.NET menu control must inherit this class.
             if (Request.ServerVariables["

http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
                 Page.ClientTarget = "uplevel"; 
}