/// <summary> /// 构造二级域名的Url(开发人员请根据项目需求,确定该处是否该使用本方法)。 /// </summary> /// <param name="sellerSysNo"></param> /// <param name="pageSysNo"></param> /// <returns></returns> public static string BuildStoreUrl(int sellerSysNo, int?pageSysNo) { List <StoreDomainPage> list = StoreFacade.GetAllStoreDomainHomePageList(); StoreDomainPage storePage = list.Find(f => f.SellerSysNo == sellerSysNo); string webDomain = ConstValue.WebDomain.TrimEnd("/".ToCharArray()); string url = "#"; if (storePage == null) { url = PageHelper.BuildUrl("StorePage", sellerSysNo, pageSysNo, false); } else { Uri uri = HttpContext.Current.Request.Url; string portName = uri.Port == 80 ? "" : ":" + uri.Port.ToString(); string domainOnlyHost = ConstValue.WebDomainOnlyHost.Trim(); url = "http://" + storePage.SecondDomain + "." + domainOnlyHost + portName + "/store/" + storePage.SellerSysNo.ToString() + "/" + storePage.HomePageSysNo.ToString(); } return(url); }
public ActionResult Index() { var routeValues = RouteData.Values; if (routeValues.Keys != null && routeValues.Keys.Count > 0) { if (routeValues.Keys.ToList <string>().Exists(f => f.ToLower() == "subdomain")) { string subdomain = routeValues["subdomain"].ToString(); if (string.IsNullOrWhiteSpace(subdomain)) { return(View()); } var forbiddenSD = AppSettingManager.GetSetting("Store", "ForbiddenSecondDomain").Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (forbiddenSD.ToList <string>().Exists(f => f.Trim().ToLower() == subdomain.Trim().ToLower())) { //该二级域名为平台专用,不可申请,所以将直接转到首页! return(View()); } StoreDomainPage storePage = StoreFacade.GetStoreIndexPageBySubDomain(subdomain.Trim()); if (storePage != null) { return(new StoreController().Index(storePage.SellerSysNo, storePage.HomePageSysNo, false)); } } } return(View()); }
/// <summary> /// 根据二级域名查找对应的商家首页 /// </summary> /// <param name="subdomain"></param> /// <returns></returns> public static StoreDomainPage GetStoreIndexPageBySubDomain(string subdomain) { List <StoreDomainPage> list = GetAllStoreDomainHomePageList(); if (list == null || list.Count == 0) { return(null); } StoreDomainPage result = list.Find(f => f.SecondDomain.Trim().ToLower() == subdomain.Trim().ToLower()); return(result); }