Connecting to Visual Studio debugging IIS Express server over the lan

前端 未结 10 919
慢半拍i
慢半拍i 2020-11-27 10:19

I have a test ASP.NET MVC3 application developed in VS2012. When I start debugging the app is accessed from the host machine via the request to http://localhost:

相关标签:
10条回答
  • 2020-11-27 10:55

    Except to modify the iisexpress configuration file, sometimes you also need to run the command like below.

    netsh http add urlacl url=http://*:49419/ user=Everyone

    0 讨论(0)
  • 2020-11-27 10:56

    Some of you might spend a lot of time modifying and testing using your %USERPROFILE% directory. If you are running on VS debug, use $(solutionDir).vs\config\applicationhost.config

    0 讨论(0)
  • 2020-11-27 10:56

    This is what worked for me:

    • Start the IIS Manager
    • Add a new virtual directory that points to the projects folder (C:\VSProjects in my case)
    • Select the new virtual directory within IIS manager. Select Directory Browsing from the list of options. On the right side there's a Enable button. Click it.

    Now I can access my folder and project bin on the network through mypcname\VSProjects\myProj\outputBinViewer.

    0 讨论(0)
  • 2020-11-27 11:01

    After the above configurations, I had to run the Visual Studio in Administrative Mode.

    0 讨论(0)
  • 2020-11-27 11:02

    Thanks to byteit:

    Go to applicationhost.config in Documents/IISExpress/config

    find the entry for the particular site you are working on:

    add:

    <binding protocol="http" bindingInformation="*:<your site port>:*" />
    

    in front of the existing

     <binding protocol="http" bindingInformation="*:<your site port>:localhost" />
    

    To achieve the solution without having VS2013 create a new website xml entry for you when you restart. You will need to run as administrator.

    0 讨论(0)
  • 2020-11-27 11:12

    How to avoid running Visual Studio as an administrator

    Using both Garret's and @shangkeyun's answer you can achieve connecting to the running website without needing to run Visual Studio as an admin user:

    1. Open %USERPROFILE%\My Documents\IISExpress\config\applicationhost.config
    2. Search for your site using name=MySiteName
    3. Duplicate the existing <binding> item in the <bindings> section. You should now have two lines with binding.
    4. Remove the "localhost" part in bindingInformation.
    5. It should now look like this, assuming the port is 12345:

      <binding protocol="http" bindingInformation="*:12345:localhost" />
      <binding protocol="http" bindingInformation="*:12345:" />
      
    6. Enable non-admin to bind to port

      netsh http add urlacl url=http://*:12345/ user=Everyone
      

    EDIT 2019: gregmac added a step to whitelist the VS instance. I never needed this, but listing it anyway:

    1. netsh advfirewall firewall add rule name="IISExpress visualstudio app" protocol=tcp localport=12345 dir=in action=allow
    0 讨论(0)
提交回复
热议问题