I am trying to serve several virtual hosts from the same code base. One thought that I was passing the HTTP Host header as the root value because I did not want to rely on HTTP contacts in controllers due to unit controller.
I had planned to highlight this root value in a controller, like the base class or something like this, I tried to pass this way as a path value:
way. The parameter new {host = HttpContext.Current.Request.Url.Host, controller = "home", with the MapRoute ("default", // root name "{controller} / {action} / {id}", // URL. Action = "Index", ID = UrlParameter.Optional} / / parameter defaults); This creates an HttpException: The request is not available in this context.
Any ideas or suggestions would be appreciated in a better way to do this.
You should rely on references while testing your controller. The routing system is designed with a test qualification so that you can set a fake context, which provides the correct URL when running your tests.
Your code does not work, hence the reason is that you are trying to apply it to the global Application_Start event that happens before the request first arrives. This means that there is no HTTTintact object available at that time.
Comments
Post a Comment