ChatGPT解决这个技术问题 Extra ChatGPT

Configure IIS Express for external access to VS2010 project

I am developing a project in VS2010 and am able to view my site locally via IIS Express. I would like to enable external access over the network.

All my research has sent me to this blog entry: http://blogs.iis.net/vaidyg/archive/2010/07/29/serving-external-traffic-with-webmatrix-beta.aspx, which is helpful but does not seem to show how to configure bindings for a project started in visual studio (I cannot find the screen in the screenshots, and I have edited binding info in applicationhost.config, but it does not seem to be reflected when I run the site from visual studio).

please read Scott Hanselman blog post hanselman.com/blog/…
possible duplicate of IIS Express enable external request

B
Ben

1 After editing applicationhost.config file (located in the IISExpress folder in your documents), your site bindings should look like below:

<bindings>
  <binding protocol="http" bindingInformation="*:8080:*" />
</bindings>

Bindings consist of three parts. Firstly an IP address or list, or as in this case, a wildcard. Secondly the port number, and thirdly a hostname, or list, or wildcard (for filtering by Host header). For development purposes, a wildcard is most suitable here as you will likely be using a unique port.

2 Because you are using non-localhost binding, additional permissions are required. You could run VS as administrator, or preferably you should add URL ACLs to grant the required permissions. In the example below permission is given to everyone, but you could use your own username.

Note: The urlacl must exactly match the binding. So a urlacl for http://*:8080 will allow a binding of *:8080:*, but not a binding of *:8080:localhost even though the latter is a subset of the former. this means if, instead of using a wildcard, you list host headers in applicationhost.config, you must add a matching urlacl for each.

The steps for configuring HTTP.sys for external traffic are similar to setting up a site to use a reserved port. On Windows 7 or Windows Vista, from an elevated command prompt, run the following command: netsh http add urlacl url=http://*:8080/ user=DOMAIN\username On Windows XP, run the following command from an elevated command prompt: httpcfg set urlacl /u http://*:8080/ /a D:(A;;GX;;;WD)

Note 2 If running VS as administrator or adding ACL entries doesn't solve your problem, then run IIS Express from the command line and check if there are any binding registration failure messages. To start from the command line, give this command:

iisexpress.exe /site:"your-site-name"

3 Finally you will need appropriate firewall entries. For this it is easiest to use the "Windows Firewall with Advanced Security" console.

Under "Inbound Rules" choose "New Rule...".

Rule Type is "Custom".

Program is Services->Customize...->Apply to services only. (Although IIS Express is not a service, the HTTP multiplexer it uses is).

Protocol is TCP

Specific Ports: List all the ports for all of your IIS Express bindings. You can come back to this rule and add ports at any time. (If this becomes tiresome, you might add a range such as 40000-65534 which covers the entire range used by Visual Studio, but be aware this is less secure).

Action is "Allow the connection"

Profile will be one of the following. If in doubt, choose "Domain + private". "Domain", If yours is a corporate desktop and will only be running on the local domain "Domain + Private" If yours is a private development machine in a non-corporate environment, or a corporate laptop which also needs to work when working from home. "Domain, Private and Public", if you need to do demonstrations on non-private networks.

"Domain", If yours is a corporate desktop and will only be running on the local domain

"Domain + Private" If yours is a private development machine in a non-corporate environment, or a corporate laptop which also needs to work when working from home.

"Domain, Private and Public", if you need to do demonstrations on non-private networks.

Name should be something like "IIS Express Dev Server"


@user578913 So I finally found the correct applicationhost.config file by opening the running IIS Express taskbar thing and clicking on it then on the link to the config file. I set the port to 1063 on the second line, as that is what the first line had been set to. Ran your command line, and everything looked fine. When I go to machine-name or machine-name:1063 from another machine on the network, I still get nothing.
ok, since Visual Studio assigns a port (other than 8080), Windows Firewall was blocking it. After shutting off Windows Firewall (I could arguably just open the port, but I'm on a secure network) and using my machine's IP rather than the machine name, it worked. Thanks. I'd vote up, but don't have the rep yet =(
Yes, if Windows Firewall needs to be on then you explicitly add the TCP port 8080 (or what you use). In Windows 7, initially I tried assigning port to "IIS Express Worker Process". But it did not work. I had to use "New Rule" option and allow port 8080. Choosing of profile (Domain, Private, Public) is also important.
Note To Self : If you get Access Denied, Run Visual Studio as Admin.
As of VS2015, the file location is C:\<Path\To\Solution>\.vs\config\applicationhost.config. (Thanks, @Talon)
f
forsvarir

I spent hours on this issue as well, trying to browse from my Android Xoom to my win7 dev machine, so I could test a new asp.net web app I created. All I did was change IISExpress' applicationhost.config from using the PC HostName to the PC's current IP address, for my new site.

<binding protocol="http" bindingInformation="*:80:dev-Lee" />

to

<binding protocol="http" bindingInformation="*:80:192.168.1.102" /> 

Once I did this & re-started IISExpress... I was able to browse to my dev-Lee machine & see my app from my Xoom!


All I get with all these solutions is an error 400 - Bad Request. Any suggestions?
@Krumelur, make sure you edit the correct applicationhost.config file. the one in My Documents folder.
N
Nasir Mahmood

We can add multiple binding addresses by editing applicationhost.config of IIS Express

<bindings>
   <binding protocol="http" bindingInformation="*:62217:localhost" />
   <binding protocol="http" bindingInformation="*:62217:192.168.0.5" />
   <binding protocol="http" bindingInformation="*:62218:192.168.0.5" />
</bindings>

Now we can access web site from lan using IP address.

Accessing local sites from Lan using IIS Express


J
Jon Eldridge

Visual Studio 2013 SP1 and above (2015) includes the setting "Apply server settings to all users (store in project file)". This is enabled by default. When enabled Visual Studio launches IIS Express with command line arguments that make it use a different configuration file. The location of the 'applicationhost.config' file is under the project directory in '.vs\config'.


Yep, that was the problem in my case - I tried to edit an incorrect file. As it happens, you can see where the config for your IIS Express app is by clicking on the tray icon, listing all apps and selecting your. The path to the config file will be written below. My was in .vs\config
Yep, same for me. Thank you very much.
J
Jim W says reinstate Monica

We made a free VS (2012, 2013, 2015) extension called Conveyor that allows this - you can find it through the Tools->Extensions... menu in VS or on the gallery site https://visualstudiogallery.msdn.microsoft.com/a429dbb7-a982-4541-b401-934375c02c0f?SRC=Home


This is brilliant and so easy to set up. Thanks for the work!
D
Daniel Eisenreich

If you're working with Visual Studio then follow these steps to access the IIS-Express over IP-Adress:

Get your host IP-Adress: ipconfig in Windows Command Line GoTo $(SolutionDir).vs\config\applicationHost.config Find Add: with your IP-Adress Run your Visual Studio with Administrator rights and everything should work Maybe look for some firewall issues if you try to connect from remote

The clue is, that Visual Studio got it's own applicationHost.config file!


s
stu

I had a lot of trouble getting this to work from visual studio 2012, I went from 404 errors to 503 errors. Eventually what worked for me, was to wipe out all the related configuration in the IIS Express config...

"\Program Files (x86)\IIS Express\appcmd.exe" list site
"\Program Files (x86)\IIS Express\appcmd.exe" delete site xxx
"\Program Files (x86)\IIS Express\appcmd.exe" delete site yyy

Then I created a new virtual directory from the properties page in my web project in VS but before I created the virtual directory I changed the hostname to http://myhost:80/ then hit the create virtual directory button. Previously I had been getting errors saying the hostname must be 'localhost' but this time it did not. And after that, it worked.

In short, clear out the existing config first and start again.


L
Leigh

If you external domain is "name.mydyndns.com", then you need to write:

<binding protocol="http" bindingInformation="*:name.mydyndns.com" />

This works on Windows 2003 Server and IIS 7.5 Express.


R
René Vogt

https://i.stack.imgur.com/gmEmv.png

in the application pool on IIS set "Enable 32-Bit Applications" to "true".


Not sure this is actually addressing the question. Did you mean to post this on another question?