routes.Add("DomainRoute", new DomainRoute(
"{controller}.localhost:5096",
"{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
));
without iis all good
with iis I have
Bad Request – Invalid Hostname
HTTP Error 400. The request hostname is invalid.
My guess is that you need to change your hosts file (C:\Windows\System32\drivers\etc\hosts) to route that subdomain to 127.0.0.1. By the way, the hosts file does not accept wildcards, so you will need to list each of your subdomains. This should not be a problem when running outside localhost since you will be able to use wildcards.
I’ve done something similar, but in my case I’ve used fixed subdomain names, but I think it may help you.