IIS Express is activated through visual studio debugging, but by default refuses remote connections. This can be a bit frustrating. We present an interesting workaround that enables remote connections for your development server.
- Start Visual Studio with Administrator priviliges by right clicking VS icon and selecting run as administrator.
- Locate
applicationhost.config
- If you use Visual Studio 2015, you will find it in
$(solution_path)\.vs\config\
- Else, you will find it in
c:\Users\<USERNAME>\Documents\IISExpress\config\
- If you have both, edit both.
- If you use Visual Studio 2015, you will find it in
- Use search function to locate site name. You will see bindings entry containing information for localhost. Add a new binding for your local IP address.
- Create an incoming firewall rule for the port of your web application.
Binding Example
Supposing that your development server IP is 192.168.1.2 and that your web application listens to port 9999, edit applicationhost.config and add a binding like the one within the emphasized text below:
<site name="web_app" id="10"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="C:\test" /> </application> <bindings> <binding protocol="http" bindingInformation="*:9999:localhost" /> <binding protocol="http" bindingInformation="*:9999:192.168.1.2" /> </bindings> </site>
If your development machine changes IP addresses too frequently, you may wish to allow all IP’s by modifying binding information like this: bindingInformation=”*:9999:*”
How to locate applicationhost.config?
Start debugging as usual. IIS Express will be activated in a while, right click IIS tray icon, and select “Show all applications”. A dialog presenting running IIS applications will pop-up. Watch the hypelink at the botton of the small dialog linking to IIS configuration file. After adding binding, save config and restart Visual Studio with admin priviliges.
But if you have Visual Studio 2015, you will also have to edit applicationhost.config that you will find in $(solution_path)\.vs\config\
If you have both applicationhost.config’s, edit both.
Add an incoming firewall rule (using command prompt)
Open command prompt with elevated privileges and type:
netsh advfirewall firewall add rule name="Open Port 9999" dir=in action=allow protocol=TCP localport=9999
Αφήστε μια απάντηση