1

Thanks for looking!

Background

I am developing a web app on the .NET 4.5 framework (C#) that needs to allow users to create an account and then have a subdomain with their account name (e.g. "foobar.myDomain.com").

I realize that this needs to involve wildcard subdomains in IIS--no problems there. And I followed this SO post for setting up a custom route to intercept the URL requests and parse out the subdomain. That seems like it will work great.

Question

How the heck do I test wildcard subdomains in localhost?? When I hit something like "foo.localhost" I just get a 404.

Any help would be appreciated!

Community
  • 1
  • 1
Matt Cashatt
  • 23,490
  • 28
  • 78
  • 111
  • Have you tried adding the subdomains to your Host file? Add one for each subdomain you want to test. – AdamV Feb 11 '13 at 22:56
  • Thanks, but that kind of defeats the purpose--I need this to behave like the production version will (dynamically). – Matt Cashatt Feb 11 '13 at 23:01
  • You can't as you need to point at localhost still. So create a user called jimmy. Then add jimmy.localhost to your hosts file. This will allow you to test it works. Done something similar very recently, it will provide what you need. You just can't test anything without modifying the hosts file when you add a test user. – Dan Saltmer Feb 11 '13 at 23:17
  • Bah! That stinks! Oh well, thanks. – Matt Cashatt Feb 11 '13 at 23:26
  • possible duplicate of [How to test subdomains on a development machine? abc.localhost](http://stackoverflow.com/questions/872868/how-to-test-subdomains-on-a-development-machine-abc-localhost) – Jeremy Thompson Feb 12 '13 at 02:03

1 Answers1

2

Tip: Don´t use localhost, use something like 42foo.com, xip.io, etc.

42foo.com has a wildcard DNS entry that always resolves to localhost.

42foo.com
foo.42foo.com

xip.io resolves to a specific IP adress you can give to it:

127.0.0.1.xip.io
foo.127.0.0.1.xip.io
elaforma
  • 652
  • 1
  • 9
  • 29