1

I am running a WCF service thru Visual Studio (2015) and IIS Express.

enter image description here

I can navigate to http://localhost:50122/TestService.svc

enter image description here

What I want to do instead is navigate to http://machine-name:50122/TestService.svc

enter image description here

How do I configure IIS Express to accept machine-name, instead of localhost?

What I tried without success:

  1. In Visual studio Project / Properties / Web / try to change Project Url to http://machine-name:50122/ but VS prevents this !

  2. In the visual studio solution folder there is a hidden .vs\config folder. Within it, there is a file: applicationhost.config; I added another binding (second line) with machine-name

<bindings>
  <binding protocol="http" bindingInformation="*:50122:localhost" />
  <binding protocol="http" bindingInformation="*:50122:intel-nuc" />
</bindings>
  1. If it's useful, both http://localhost and http://intel-nuc both work (default port 80) and point to the default IIS provided demo page - But those are being served by IIS (not IIS Express).
joedotnot
  • 4,810
  • 8
  • 59
  • 91

1 Answers1

0

Found this on stackoverflow: How to enable external request in IIS Express? , which also applies to "internal" request.

The command I used (Run as Admin)

netsh http add urlacl url=http://intel-nuc:50122/ user=everyone

Afterwards, you also need to run VS as Admin.

joedotnot
  • 4,810
  • 8
  • 59
  • 91
  • If a URL reservation is created via netsh, then you don't need to run VS as administrator for IIS Express to bind to that URL. – Lex Li Nov 16 '20 at 16:50
  • @LexLi theory is different than practice, I actually tried VS without Admin at first, IIS Express would not start, said something about requiring admin permissions. – joedotnot Nov 16 '20 at 17:01
  • @LexLi, to further clarify, I noticed that when I run as Admin, IIS serves both http://localhost:port and http://machine-name:port; (as shown in System Tray). But if I run without admin, only http://machine-name;port starts; In other words, you are probably correct in saying that Admin is not needed, BUT THEN Admin is now needed for localhost !! – joedotnot Nov 16 '20 at 17:34
  • Then you can `netsh http add urlacl url=http://localhost:50122/ user=everyone` to register to all addresses, without run as Admin at all! – ChrisTorng Aug 24 '21 at 07:37