Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 392
FireNacho Avatar asked Aug 31 '17 16:08

FireNacho


People also ask

Can IIS Express be accessed remotely?

Normally when you run an application in IIS Express, it's only accessible on http://localhost:[someport]. In order to access it from another machine, it needs to be bound to your public IP address as well.

How do I enable IIS Express in Visual Studio 2017?

Select the ASP.NET Core project in Visual Studio Solution Explorer and click the Properties icon, or press Alt+Enter, or right-click and choose Properties. Select the Debug tab. In the Properties pane, next to Profile, For IIS Express, select IIS Express from the dropdown.

How do I use Visual Studio with IIS Express?

Configure IIS express on visual studio Select the web application project and open properties -> select the web tab -> under server's select IIS express-> Specify the project URL. Now open the project folder and . vs folder (Hidden) -> Config -> applicationhost.

How do I host a website on IIS Express?

C:\Program Files (x86)\IIS Express and click on the iisexpress application . Open up Visual Studio . Open any Web Project which you would like to host . I have opened a Silverlight project here .


2 Answers

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.

like image 135
JasonPlutext Avatar answered Oct 12 '22 07:10

JasonPlutext


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.

like image 36
Vladimir.RL Avatar answered Oct 12 '22 06:10

Vladimir.RL