/// <summary> /// 根据当前的请求地址,查找对应的站点。 /// 1. 预览模式 dev~ + 站点名称 /// 2. 正式访问 域名 + site path /// </summary> /// <param name="httpContext">The HTTP context.</param> /// <returns></returns> public SiteMappedContext MapSite(HttpContext httpContext) { Contract.Requires(httpContext != null); foreach (var item in _events) { item.PreMapSite(this, new PreMapSiteEventArgs(httpContext)); } var mappedContext = _siteRequestFlow.MapSite(httpContext); foreach (var item in _events) { var args = new PostMapSiteEventArgs(httpContext, mappedContext); item.PostMapSite(this, args); //替换事件中可能重新查找的站点。 mappedContext = args.MappedContext; } return(mappedContext); }
/// <summary> /// 根据当前的请求地址,查找对应的站点。 /// 1. 预览模式 dev~ + 站点名称 /// 2. 正式访问 域名 + site path /// </summary> /// <param name="httpContext">The HTTP context.</param> /// <returns></returns> public SiteMappedContext MapSite(HttpContext httpContext) { Contract.Requires(httpContext != null); foreach (var item in _events) { item.PreMapSite(this, new PreMapSiteEventArgs(httpContext)); } var mappedContext = _siteRequestFlow.MapSite(httpContext); foreach (var item in _events) { var args = new PostMapSiteEventArgs(httpContext, mappedContext); item.PostMapSite(this, args); //替换事件中可能重新查找的站点。 mappedContext = args.MappedContext; } return mappedContext; }