16

I'm trying to configure a new ASP.NET MVC3 using IIS7 express (on my local development machine) to use a custom domain name.

eg.

  1. my local dev machine.
  2. kick open my web browser
  3. goto http://dev.www.mydomain.com
  4. my visual studio mvc project kicks in

I've hacked my hosts file to include (yes, i saved the file .. which also meant i had to have admin rights enabled ...

127.0.0.1 dev.www.mydomain.com

I just can't figure out how to use IIS7 express to get configured to do this.

I went to MVC Project => Properties => Web and did the following :- enter image description here

Then tried to run the site... enter image description here

Can anyone help?

Pure.Krome
  • 84,693
  • 113
  • 396
  • 647

2 Answers2

19
  1. Stop currently running site if it is running

  2. Open %userprofile%\documents\iisexpress\config\applicationhost.config
    for VS2015+ :$(solutionDir)\.vs\config\applicationhost.config

  3. Locate the site you are interested in and it would have a binding like

    <binding protocol="http" bindingInformation="*:<your-port-number>:localhost" />

  4. Now add a similar entry <binding protocol="http" bindingInformation="*:<your-port>:dev.www.mydomain.com" /> just below the above bindig entry.

  5. run the site again

NOTE: You must start visual studio as administrator because non-localhost binding requires administrator privileges


Update By Pure Krome:

Further to this, we need to do the following. These comments are in the top of my web.config (along with a few other stuff...).

1) netsh http add urlacl url=http://localhost.www.foo.com:80/ user=everyone
   netsh http add urlacl url=http://localhost.foo.com:80/ user=everyone
   netsh http add urlacl url=http://localhost.foobar.com.au:80/ user=everyone
   netsh http add urlacl url=http://localhost.pewpew.com:80/ user=everyone
   ... etc ... 
   NOTE: to remove a urlacl: netsh http delete urlacl url=<url in here> .. eg http://foo.com:80

2) ... and we need to edit the main IIS7 express config file to define the url's which will be accepted, per web -site-
    File: C:\Users\<UserName>\Documents\IISExpress\config\applicationhost.config
<bindings>
    <binding protocol="http" bindingInformation="*:1200:localhost" />
    <binding protocol="http" bindingInformation="*:80:localhost.www.foo.com" />
    <binding protocol="http" bindingInformation="*:80:localhost.foo.com" />
    <binding protocol="http" bindingInformation="*:80:localhost.foobar.com.au" />
    <binding protocol="http" bindingInformation="*:80:localhost.pewpew.com" />
</bindings>
Community
  • 1
  • 1
vikomall
  • 17,379
  • 6
  • 49
  • 39
  • @user578913 - frak me .. are you serious????? I have to now get every member in my team to *manually* edit their apphost.config file ?? WTF! :( – Pure.Krome Mar 17 '11 at 22:57
  • I am afraid you have to do that @pure ... but I sure hope they will fix this. You could also create a small power shell script for it. – Syska Aug 23 '11 at 21:34
  • @Syska - yep, i've forgotton about this question. I've been using this technique since i got this answer. It works wonderfully! I've just got a comment at the top of our web.config with commands (ps command line) how to do this. In fact, i'll update this answer. – Pure.Krome Aug 25 '11 at 00:34
  • YOWZA WOWZA This is helpful. YOWZA WOWZA – Ronnie Overby Nov 07 '12 at 15:22
-1

I have successfully been able to accomplish debugging an IIS7-bound site similar to the above. The only step it appears you are missing is within your project:

  1. Select Project => [Project] Properties from the menu
  2. Click the "Web" section
  3. Select the "Use Custom Web Server" option, and set Server Url to "http://dev.www.my-domain.com"
Keith
  • 5,311
  • 3
  • 34
  • 50