14
votes

Been looking through and trying all guides i found on this topic but no luck. I am running and MVC project with HTTPS and want to access the debug site with some remote mobile devices to test out the website. I followed a guide that almost work and i think I am pretty close to getting it to work. Here are the steps I have done:

  • Turn off Firewall
  • Open projectfolder of website go to \vs\config\ and open applicationhost.config
  • Find your site and line that contains your mapped port like this:

-edit it to get this result:

  • Tried to run Visual Studio as Admin at this point, Got regular error 400: Bad Request - Invalid Hostname when trying to access site from other computer
  • Opened CMD as Admin and ran the following command:

netsh http add urlacl url=http://*:44363/ user=everyone - URL reservation successfully added

-Tried to start Visual studio as admin and non admin. Gets the following error message

"Unable to launch the IIS Express Web Server. Failed to reister URL "https://localhost:44363" for site "x" Application. Error description: Cannot create file when that file already exists"

-I then have to run cmd again and remove the url with the command: netsh http delete urlacl url=http://*:44363/

How do i get this to work with Visual Studio 2017 ? I cant be many steps from getting it to work. I have read many guides but none of them works

3
Our free VS extension 'Conveyor' is a simpler alternative to all these config modifications, it easily opens up IIS Express to remote access marketplace.visualstudio.com/…Jim W says reinstate Monica

3 Answers

21
votes

Amazing how such a simple common need can be so painful to fulfill out of the box in 2017!

Anyway https://github.com/icflorescu/iisexpress-proxy worked nicely for me.

Install it with node:

npm install -g iisexpress-proxy

Then its just something like:

iisexpress-proxy 51123 to 3000

Under 2 mins to get running.

5
votes

Let me share my experience with Visual Studio and IIS Express that should help you. I am not using HTTPS and my project type is Web site with WCF but you should be able to accomplish your goal. Here are prerequisites:

  1. IIS Express installed
  2. Visual Studio installed
  3. Added url reservation for public port (netsh http add url=http://*:50001/ User=Everyone) from elevated command prompt.
  4. Added firewall inbound rule for 50001 TCP port (Control Panel-->Windows Firewall-->Advances Settings-->Inbound Rules-->New Rule...)

Now let us setup a project in VS. I am using one of predefined templates with C#. Compile it and try to run it from VS. At that moment VS is starting developer instance of IISExpress that helps your site to run. You should be able to see IIS Express icon in Notification area. With right click you will see that your site is running and a port (we will call it VSPORT) that is assigned by VS. This port must be different than reserved port (50001). If you managed to accomplish this without problems then you have almost everything ready for running your site without VS.

  1. Go to your project folder
  2. Go to .vs folder
  3. Go to config folder
  4. Open applicationhost.config
  5. Locate sites/your_site section
  6. Copy everything between your_site and /your_site

Now we need to add this info in "global" IIS Express config.

  1. Go to IIS Express folder (something like c:\Users\USERNAME\Documents\IISExpress)
  2. Go to config folder
  3. Open applicationhost.config
  4. Locate sites section.
  5. Paste information about your site.
  6. Change binding from

binding protocol="http" bindingInformation="*:VSPORT:localhost"

to

binding protocol="http" bindingInformation=":50001:"

  1. Save changes

With this change you may start IISExpress.exe directly and you can continue to use VS to work on you project at the same time.

If you want to access it from other computers do it as http://YOURIP:50001/. Do have in mind that you need to ensure that your javascript code is NOT using address and port number directly.

4
votes

You can solve the problem by downloading the 'conveyor' library from extensions and update in Visual Studio.

You can access it from other devices.

  • Open Visual Studio

  • Tools > Extensions and Updates

  • Online > Visual Studio Marketplace

  • Search 'Conveyor'
  • Download and install this extension

When you launch the API, you can access it from other devices. This plugin creates a link from your own ip address.

Example: https://youripadress:5000/api/values