I am trying to serve multiple virtual hosts from the same code base. One thought I had was pass the HTTP Host header as a route value because I did't want to rely on HttpContext in the controllers because of unit testability.
I had planned on exposing this route value in a controller base class or something like that. I tried passing as a route value like this:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { host = HttpContext.Current.Request.Url.Host, controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
This yields an HttpException: Request is not available in this context.
Any ideas or suggestions on a better way to do this would be appreciated.