Visual Studio 2017 - Giving remote users access to website in IIS Express
Asked Answered
G

4

14

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

Geoponics answered 31/8, 2017 at 16:54 Comment(1)
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/…Gabon
L
22

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.

Longdrawn answered 13/5, 2018 at 2:47 Comment(1)
instant upvote just for this sentence: Amazing how such a simple common need can be so painful to fulfill out of the box in 2017!Apogeotropism
Z
5

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.

Zetana answered 2/9, 2017 at 23:17 Comment(3)
Thanks for the feedback ! I decided not to use more time fiddling with IIS Express and instead installer the full IIS version and use that instead. This worked fine and was minimal work compared to everything I have tried with IIS Express.Geoponics
It works but in vs 2017 there is localhost and if I try to open the site from ip it returns "Bad Request - Invalid Hostname"Nonresistant
@Nonresistant I am not sure what are you trying to do: A) To start IIS Express and then access your site from other computer B) To access your site from VSZetana
S
5

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

Symphonic answered 22/10, 2019 at 23:24 Comment(0)
L
0

All of the answers here will work, but I was doing something just a little wrong for all of them. Let me add some additional details that snagged me. Here is how I got up and running using VS 2022:

  1. Navigate to C:\Users\Your Username\source\repos\Your Website\.vs\Your Website\config

  2. Open applicationhost.config in a text editor

  3. Use the search function to find your site under <sites>. It should look similar to <site name="Your Website" id="1">.

  4. Under your site you can find the bindings section and there should be bindings present for localhost. One for https and one for http like:

<bindings>
     <binding protocol="https" bindingInformation="*:44345:localhost" />
     <binding protocol="http" bindingInformation="*:57640:localhost" />
</bindings>
  1. Add an https AND http binding for a wildcard hostname like:
<bindings>
     <binding protocol="https" bindingInformation="*:44345:localhost" />
     <binding protocol="https" bindingInformation="*:44345:*" />
     <binding protocol="http" bindingInformation="*:57640:localhost" />
     <binding protocol="http" bindingInformation="*:57640:*" />
</bindings>
  1. Save applicationhost.config and restart Visual Studio as Administrator. To repeat Visual Studio has to be running as Administrator to accept connections from any ip outside of localhost! Not even 127.0.0.1 loopback will work without Admin privileges.

  2. Run your application and try navigating to <yourip>:<yourport>. To note If you want to run https, you will have to enter https:/<yourip>:<yourport>!

This is how I got up and running and most of this information is courtesy to an SO answer here.

Loudhailer answered 18/7, 2024 at 11:29 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.