/*
 * 项目名称:N3software
 * 创建日期:2006-06-27
 * 版 本 号:1.0.0.0
 * 技术支持:http://www.n3software.com
 * 电子邮箱:[email protected] 
 */using System;
using System.Web;namespace N3software.Class
{
/// <summary>
/// RegValidate 的摘要说明。
/// </summary>
public class RegValidate
{
protected int m_nMaxRegWeb = 100, m_nHasRegWeb = 0;
protected string [] m_aryRegWeb;
public RegValidate()

// 网站域名注册信息
m_aryRegWeb = new string[m_nMaxRegWeb];
AddRegWeb( "127.*.*.*|2006-06-10|2008-06-10" );
AddRegWeb( "192.*.*.*|2006-06-10|2008-06-10" );
AddRegWeb( "10.*.*.*|2006-06-10|2008-06-10" );
AddRegWeb( "172.*.*.*|2006-06-10|2008-06-10" );
AddRegWeb( "localhost|2006-06-10|2008-06-10" ); 
AddRegWeb( "netfree.meibu.com|2006-06-10|2008-06-10" );
}public string Check()
{
string strResult = "此访问地址注册无效";
string strWebName = "", strCurrentDate = "", strTemp = "";
string strStartDate = "", strEndDate = "";
string [] aryTemp;
int i = 0;strWebName = GetWebName().ToLower();
strCurrentDate = GetCurrentDate();// 内网IP地址检测
strTemp = strWebName.Substring( 0, 3 );
if ( strTemp == "127" || strTemp == "192" || strTemp == "10." || strTemp == "162" )
{
for ( i=0; i<m_nHasRegWeb; i++ )
{
if ( m_aryRegWeb[i].Substring( 0, 3 ) == strTemp )
{
strTemp = m_aryRegWeb[i];
strResult = "OK";
break;
}
}
}// 域名检测
for ( i=0; i<m_nHasRegWeb; i++ )
{
aryTemp = m_aryRegWeb[i].Split( '|' );
if ( aryTemp[0] == strWebName )
{
strTemp = m_aryRegWeb[i];
strResult = "OK";
break;
}
}// 使用超时检测
if ( strResult == "OK" )
{
aryTemp = strTemp.Split( '|' );
strResult = "注册日期使用超时"; // 重设为失败值
strStartDate = aryTemp[1].ToString(); // 使用开始日期
strEndDate = aryTemp[2].ToString(); // 使用结束日期
if ( strCurrentDate.CompareTo( strStartDate ) >= 0 && strCurrentDate.CompareTo( strEndDate ) <= 0 )
{
strResult = "OK";

}// 最终结果检测
if ( strResult != "OK" )
{
strResult = string.Format( " \"{0}\" {1}, 请联系服务供应商 (软件项目开发网 http://www.n3software.com)", strWebName, strResult );
}return strResult;
}private bool AddRegWeb(string strRegWeb)
{
bool bResult = true;
if ( m_nHasRegWeb < m_nMaxRegWeb )
{
m_aryRegWeb[m_nHasRegWeb++] = strRegWeb;
}
else
{
bResult = false;
}return bResult;
}private string GetWebName()
{
string strResult = "", strTemp = "", strTemp2 = "";
HttpRequest Request = HttpContext.Current.Request;
strTemp = Request.Url.ToString();
for ( int i=7; i<strTemp.Length; i++ )
{
strTemp2 = strTemp.Substring( i, 1 );
if ( strTemp2 != "/" )
{
strResult += strTemp2;
}
else
{
break;
}
}
return strResult;
}private string GetCurrentDate()
{
string strResult = "";
strResult = DateTime.Now.ToString( "yyyy-MM-dd" );
return strResult;
}
}

调用例子
比如在数据库访问接口加入  RegValidate rvRegValidate = new RegValidate();
  string strTemp = rvRegValidate.Check();
  if (  strTemp != "OK" )
  {
      throw new Exception( strTemp );
  }