If i have the following URL:
/someurl
And i have two domain names:
us.foo.com
au.foo.com
I want this to 200 (match):
us.foo.com/someurl
But this to 404 (not match):
au.foo.com/someurl
The route looks like this:
RouteTable.Routes.MapRoute(
"xyz route",
"someurl",
new { controller = "X", action = "Y" }
);
I'm guessing because there are no route values, i can't constraint the URL based on the host? Is that correct?
If so, how can i do this, other than the following (ugly) in the action:
if (cantViewThisUrlInThisDomain)
return new HttpNotFoundResult();
Anyone got any ideas?
I guess i'm kind of looking for a way to constraint a route via it's domain, not the route token, if that makes sense.
You could write a custom route:
and then register it in the
RegisterRoutes
method inGlobal.asax
: