private AbsolutPathData ParameterSubdomain(VirtualPathContext context, string subdomainParameter) { var hostBuilder = BuildUrl(context, context.Values[subdomainParameter].ToString()); //we have to remove our subdomain so it will not be added as query string while using GetVirtualPath method var values = new RouteValueDictionary(context.Values); values.Remove(ParameterNameFrom(Subdomain)); var path = base.GetVirtualPath(new VirtualPathContext(context.HttpContext, context.AmbientValues, values)); if (path == null) { return(null); } return(new AbsolutPathData(this, path.VirtualPath, hostBuilder.ToString())); }
public override VirtualPathData GetVirtualPath(VirtualPathContext context) { if (Subdomain == null) { //if route is without subdomain and we are on host without subdomain use base method //we don't need whole URL for such case if (GetHostname(context.HttpContext.Request.Host.Value) == null) { return(base.GetVirtualPath(context)); } return(GetVirtualPath(context, context.Values, BuildUrl(context))); } var subdomainParameter = IsParameterName(Subdomain) ? ParameterNameFrom(Subdomain) : Subdomain; var containsSubdomainParameter = context.Values.ContainsKey(subdomainParameter); var defaultsContainsSubdomain = this.Defaults.ContainsKey(subdomainParameter); if (IsParameterName(Subdomain)) { var sParameter = ParameterNameFrom(Subdomain); if (context.Values.ContainsKey(sParameter)) { return(ParameterSubdomain(context, context.Values[subdomainParameter].ToString())); } else if (this.Defaults.ContainsKey(sParameter)) { return(ParameterSubdomain(context, this.Defaults[sParameter].ToString())); } } else { if (!IsParameterName(Subdomain)) { return(StaticSubdomain(context, subdomainParameter)); } } return(null); }
protected abstract VirtualPathData OnVirtualPathGenerated(VirtualPathContext context);
public VirtualPathData GetVirtualPath(VirtualPathContext context) { // Nothing to do. return(null); }
protected override VirtualPathData?OnVirtualPathGenerated(VirtualPathContext context) { return(_target.GetVirtualPath(context)); }
public VirtualPathData GetVirtualPath(VirtualPathContext context) { return(new VirtualPathData(this, "")); }
public VirtualPathData GetVirtualPath(VirtualPathContext context) { return(null); }
private AbsolutPathData StaticSubdomain(VirtualPathContext context, string subdomainParameter) { var hostBuilder = BuilSubdomaindUrl(context, subdomainParameter); return(GetVirtualPath(context, context.Values, hostBuilder)); }