I'm currently working on a DomainRoute class, which would enable routing based on (sub)domains, so for example http://products.example.com maps to the ProductsController.
So far so good, route parsing and stuff like that is no problem. However, I'm hitting a wall here. Let's have a look at this code snippet:
1 public class DomainRoute : RouteBase
2 {
3 // ...
4
5 public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
6 {
7 // ...
8 // Some logic happens here, and url is generated
9 // into someting like "http://account.example.com/Register"
10 // ...
11
12 return new VirtualPathData(this, url);
13 }
14 }
This GetVirtualPath method returns a virtual path (in a VirtualPathData instance) based on the request context and the route dictionary values, which is then used by for example the HtmlHelpers.ActionLink() method. Now say we have some logic that generates a URL like "http://account.example.com/Register". Problem here is that this URL is treated as a virtual path, meaning that the URL rendered to my view is something like "http://localhost/http:/account.example.com/Register".
Question: does anyone have an idea on how to trick ASP.NET MVC and the routing infrastructure into treating my URL as a full URL instead of a virtual path?