2

Is there a setting in either IIS or Visual Studio 2015 Community that I can set an Impersonated URL. I would like to debug my website locally but give the debugger the impression that the site is running on a specific domain instead of localhost?

I am using DotNetBlogEngine.Net and it has features to run several websites from a single web application. I have extended it to also allow a site to have an alias so it will run the exact same site under a different domain name. Unfortunately it is not fully working and when I go to the alias website it removes the domain and replaces it with the IP address. I would like to dive into my code and attempt debug the issue. Thanks.

Enkode
  • 4,515
  • 4
  • 35
  • 50
  • 3
    maybe you could add the fake domain to your windows hosts file and let it redirect to localhost? – S. Roose Nov 28 '16 at 19:12
  • Windows Host file will not work as it will not allow for a port number and VS uses port numbers for debugging: http://stackoverflow.com/a/8652991/1452739 – Enkode Nov 29 '16 at 07:34

1 Answers1

1

There is a special domain name *.localtest.me that is specially created for this purpose by some nice people. It is special by the fact that internally it resolves into 127.0.0.1 (otherwise known as localhost).

See http://readme.localtest.me

Nice thing is that does not require any modifications to the hosts file and will work on any machine with internet connection.

You can set up any number of domain names like site1.localtest.me, site2.localtest.me, etc and they all will look like real domain names and will point to localhost.

Just set up IIS bindings and/or your blog engin using required subdomains and it will work the same as it was external domain name.

Kaspars Ozols
  • 6,967
  • 1
  • 20
  • 33
  • Thanks for the suggestion. Have you tried this with Visual Studio and got it to work? I tested and my VS Port is 44333 so I tried http://enkode.localtest.me:44333/default.aspx and it just gave me an HTTP 400 error. – Enkode Nov 29 '16 at 07:42
  • 1
    Sure, but it takes few more steps to get it to work with IIS Express. You need to add correct bindings. Please see this to http://stackoverflow.com/questions/4709014/using-custom-domains-with-iis-express/32744234#32744234 – Kaspars Ozols Nov 29 '16 at 08:23
  • Yes I found more support on this but still getting a 503 error. This has been by far the best support for it: https://www.richard-banks.org/2014/01/how-to-configure-iisexpress-for.html – Enkode Nov 29 '16 at 08:41
  • To be honest, I see no benefit in using IIS Express over regular IIS. I would suggest you to try setting up regular IIS instead as it gives much more control over web site and is much closer to the environment that you will end up with in production. – Kaspars Ozols Nov 29 '16 at 09:02
  • Finally got it work. The issue was that in Visual Studio 2015 their is a local and global applicationhost.config file. Need to do a bit more testing to see if that really will solve my issue. http://stackoverflow.com/a/32744234/1452739 – Enkode Nov 29 '16 at 09:08
  • Well your answer did help but what helped more was the comment / reference to the other question: http://stackoverflow.com/q/4709014/1452739 even then I needed another question / answer to solve the problem as I did mention VS2015 so I don't think I can award your answer the points. I can give it a vote though. – Enkode Nov 29 '16 at 09:27