mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Modified subdomain routing via url parameter.
This commit is contained in:
parent
b702e4fc2e
commit
a02e4e15e5
@ -37,7 +37,7 @@ namespace Teknik
|
||||
{
|
||||
var routeData = base.GetRouteData(httpContext);
|
||||
if (routeData == null) return null; // Only look at the subdomain if this route matches in the first place.
|
||||
string subdomain = httpContext.Request.Params["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname.
|
||||
string subdomain = httpContext.Request.QueryString["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname.
|
||||
if (subdomain == null)
|
||||
{
|
||||
string host = httpContext.Request.Headers["Host"];
|
||||
@ -52,8 +52,19 @@ namespace Teknik
|
||||
subdomain = string.Empty;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (routeData.Values["sub"] == null)
|
||||
{
|
||||
routeData.Values["sub"] = subdomain;
|
||||
}
|
||||
else
|
||||
{
|
||||
subdomain = routeData.Values["sub"].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
routeData.Values["sub"] = subdomain;
|
||||
//routeData.Values["sub"] = subdomain;
|
||||
if (subDomain == subdomain)
|
||||
{
|
||||
return routeData;
|
||||
@ -63,8 +74,8 @@ namespace Teknik
|
||||
|
||||
public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
|
||||
{
|
||||
object subdomainParam = requestContext.HttpContext.Request.Params["sub"];
|
||||
if (subdomainParam != null)
|
||||
object subdomainParam = requestContext.HttpContext.Request.QueryString["sub"];
|
||||
if (subdomainParam != null && values["sub"] == null)
|
||||
values["sub"] = subdomainParam;
|
||||
return base.GetVirtualPath(requestContext, values); // we now have the route based on subdomain
|
||||
}
|
||||
|
@ -40,20 +40,28 @@ namespace Teknik
|
||||
}
|
||||
|
||||
// Grab the sub from parameters if it exists
|
||||
string subParam = url.RequestContext.HttpContext.Request.Params["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname.
|
||||
string subParam = url.RequestContext.HttpContext.Request.QueryString["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname.
|
||||
|
||||
// If the param is not being used, we will use the curSub
|
||||
if (string.IsNullOrEmpty(subParam))
|
||||
{
|
||||
// If we are in dev, we need to keep it in dev
|
||||
firstSub = (curSub == "dev") ? "dev" : sub;
|
||||
rightUrl = url.Action(action, controller, routeValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
// sub within param will always be on the dev subdomain
|
||||
firstSub = (string.IsNullOrEmpty(curSub)) ? string.Empty : "dev";
|
||||
if (subParam != "dev")
|
||||
{
|
||||
rightUrl = url.Action(action, controller, Utility.Merge(new { sub = sub }, routeValues));
|
||||
}
|
||||
else
|
||||
{
|
||||
rightUrl = url.Action(action, controller, routeValues);
|
||||
}
|
||||
}
|
||||
rightUrl = url.Action(action, controller, routeValues);
|
||||
|
||||
domain = (string.IsNullOrEmpty(firstSub)) ? domain : firstSub + "." + domain;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user