This page relates to the legacy version of the tunnel that has been introduced to CrossBrowserTesting. If you use the new tunnel version, see Local Testing — Secure Tunnels.
I am writing a Visual Studio application and the application works on my machine but will not work on the local connection.
See here for a Stack Overflow explanation of the problem: https://stackoverflow.com/questions/14725455/connecting-to-visual-studio-…
There are a couple of ways to get around this. By default IIS Express will only serve content to URL that looks like this http://localhost.
Use smart proxy
If you decide to use this option, when you run the local connection you will need to pick the Proxy Server option in the local connection. You will put your IP address and the port of the smart proxy you will use. For Charles and Fiddler the port is usually 8888, you can check this in the proxy setting for either product.
Charles Proxy
Use the Enable Rewrite functionality to rewrite any Host header that comes in to your IP address and change it to the localhost format that IIS Express recognizes.
-
Find the Rewrite menu option in the Tools menu.
-
Click Enable Rewrite and Debug in Error Log and create a new set, Add a location and leave it blank to get the "*" everything location, then finally add a Rule.
-
In the rule make sure to include your IP address and port that the Visual Studio application is using.
-
For HTTPS to work you have to make sure that Charles is set to Enable SSL Proxying, otherwise it will not be able to modify the SSL traffic. You can find that option under Proxy > SSL Proxying Settings. Make sure that Enable SSL Proxying is checked and your IP address is added as a location.
Fiddler proxy
Use the Custom Rules to change the Host header from your IP address to the localhost format IIS Express recognizes.
-
In the Rules menu choose the Customize Rules menu option.
-
Find the method named
OnBeforeRequest
in the notepad that pops up. -
At the bottom of the
OnBeforeRequest
method add the following code. Change the code to include your IP address and port that IIS Express is using for your application.if (oSession.HostnameIs("CHANGE TO YOUR IP ADDRESS")) {
oSession.host ="localhost:YOUR_PORT_HERE";
}
Change the IIS Express setup
Changing the IIS Express setup on your machine so it allows connections other than localhost. You can either look at what theStack Overflow article https://stackoverflow.com/questions/14725455/connecting-to-visual-studio-… or our directions below.
-
You will need to run Visual Studio as admin, if you do not do this these changes will not work.
-
Backup this file: %userprofile%\documents\iisexress\applicationhost.xml.
-
Edit this file: %userprofile%\documents\iisexress\applicationhost.xml.
-
Find the site tag that matches your application.
-
Find the bindings tag for your application.
-
Change the binding (the PORT should match the port your application is using)
<binding protocol="http" bindingInformation="*:58934:localhost" />
to this
<binding protocol="http" bindingInformation="*:58949:*" />
See Also
Testing on a Local Machine
CrossBrowserTesting Local Connection Tool
FAQ