
/// <summary>
///
/// 功能描述:获取主机地址查找用户二级域名并跳转
///
/// 作 者:WangYi
///
/// 创建时间:2008/5/8
///
/// </summary>
private void GetHosttingAndToUrl()
{
string HostName = HttpContext.Current.Request.Url.Host.ToString(); //获取URL主机地址
//string HostName = "http://xxxxx.XXXXxx.com/company/index-sss.aspx";
string[] UserHost = HostName.Split(new char[] { '.' }); //数组 以.作为分隔
if (UserHost.Length <= 3)
{
string UserDomainName = UserHost[0].ToString().Replace("http://", ""); //取得数组最前面一组值,及二级域名主机头
if (UserDomainName.ToLower() == "www" || UserDomainName.ToLower() == "xxxx域名" || UserDomainName == null || UserDomainName.ToString() == "")
{
HttpContext.Current.Response.Redirect(HostName);
}
else
{
if (HostName.ToLower().IndexOf("company") > 0 && HostName.IndexOf("_") > 0 || HostName.IndexOf("-") > 0 || HostName.ToLower().IndexOf("index") > 0)
{
HttpContext.Current.Response.Redirect(HostName);
}
else
{
GetUserNameToUrl(UserDomainName);
}
}
}
else
{
HttpContext.Current.Response.Redirect(HostName);
}
}
/// <summary>
///
/// 功能描述: 获取企业用户名并进行页面跳转
///
/// 作 者:WangYi
///
/// 创建时间:2008/5/8
///
/// </summary>
/// <param name="UserName">用户名</param>
private void GetUserNameToUrl(string UserName)
{
string _entname = DALAspnet_Membership.GetUserID(UserName);
if (_entname == null || _entname == "")
{
Response.Redirect("http://www.xxxxx.com/index.html", true);
}
else
{
HttpContext.Current.Response.Redirect("~/Company/index-" + _entname + ".html");
}
}

