How to enable external request in IIS Express?

前端 未结 26 1137
借酒劲吻你
借酒劲吻你 2020-11-22 01:55

How can I enable remote requests in IIS Express? Scott Guthrie wrote that is possible but he didn\'t say how.

相关标签:
26条回答
  • 2020-11-22 02:40

    If you run Visual Studio from Admin you can add just

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

    or

    <binding protocol="https" bindingInformation="*:8443:*" />

    into

    %userprofile%\My Documents\IISExpress\config\applicationhost.config
    
    0 讨论(0)
  • 2020-11-22 02:44

    Combining answers in this thread, this is how I fixed it(Visual Studio 2019):

    1. Start Visual Studio as an Administrator and Run your Web Service as you normally do.

    2. Find IIS Express icon on the taskbar, right click on it then click "Show All Applications".

    3. Select your Web Service and note the config path displayed below. Click on the config file to open it for editing.

    4. Find your web service(example search for your port) in this config file then find a line like this: *:yourport:localhost

    5. Add a new line after that like this:

      :yourport:*

    In this case no need to create bindings with specific ip address which could change in the future.

    I hope this helps someone out there.

    0 讨论(0)
  • 2020-11-22 02:45

    I remember running into the same problems while trying this workflow a few months ago.

    Which is why I wrote a simple proxy utility specifically for this kind of scenario: https://github.com/icflorescu/iisexpress-proxy.

    Using the IIS Express Proxy, it all becomes quite simple – no need to “netsh http add urlacl url=vaidesg:8080/ user=everyone” or to mess up with your “applicationhost.config”.

    Just issue this in command prompt:

    iisexpress-proxy 8080 to 3000

    …and then you can point your remote devices to http://vaidesg:3000.

    Most of the times simpler IS better.

    0 讨论(0)
  • 2020-11-22 02:45

    I have some problems using IIS Express in Win 8.1 and external request.

    I follow this steps to debug the external request:

    1. Install IIS
    2. Configure Visual Studio to use local IIS (Page properties in your Web Project)
    3. Create a exclusive AppPool in IIS to work with my application
    4. In my Project I'm using Oracle Client and must be 32bits (64 bits don't work with Visual Studio) then I need allow 32 bit in Application Pool
    5. Configure the Windows firewall to allow request in port 80 (inbound rules)

    It's working!

    0 讨论(0)
  • 2020-11-22 02:46

    This is what I did for Windows 10 with Visual Studio 2015 to enable remote access, both with http and https:

    First step is to bind your application to your internal IP address. Run cmd -> ipconfig to get the address. Open the file /{project folder}/.vs/config/applicationhost.config and scroll down until you find something like this:

    <site name="Project.Web" id="2">
        <application path="/">
            <virtualDirectory path="/" physicalPath="C:\Project\Project.Web" />
        </application>
        <bindings>
            <binding protocol="http" bindingInformation="*:12345:localhost" />
        </bindings>
    </site>
    

    Add two new bindings under bindings. You can use HTTPS as well if you like:

    <binding protocol="http" bindingInformation="*:12345:192.168.1.15" />
    <binding protocol="https" bindingInformation="*:44300:192.168.1.15" />
    

    Add the following rule to your firewall, open a new cmd prompt as admin and run the following commands:

    netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=12345 profile=private remoteip=localsubnet action=allow
    
    netsh advfirewall firewall add rule name="IISExpressWebHttps" dir=in protocol=tcp localport=44300 profile=private remoteip=localsubnet action=allow
    

    Now start Visual Studio as Administrator. Right click the web projects project file and select Properties. Go to the Web tab, and click Create Virtual Directory. If Visual Studio is not run as Administrator this will probably fail. Now everything should work.

    0 讨论(0)
  • 2020-11-22 02:48

    There are three changes you might need to make.

    1. Tell IIS Express itself to bind to all ip addresses and hostnames. In your .config file. Typically:
      • VS 2015: $(solutionDir)\.vs\config\applicationhost.config
      • < VS 2015: %userprofile%\My Documents\IISExpress\config\applicationhost.config

    Find your site's binding element, and add

        <binding protocol="http" bindingInformation="*:8080:*" />
    
    1. Setup the bit of Windows called 'http.sys'. As an administrator, run the command:
        netsh http add urlacl url=http://*:8080/ user=everyone
    

    Where everyone is a windows group. Use double quotes for groups with spaces like "Tout le monde".

    1. Allow IIS Express through Windows firewall.

      Start / Windows Firewall with Advanced Security / Inbound Rules / New Rule...

      Program %ProgramFiles%\IIS Express\iisexpress.exe
      OR Port 8080 TCP

    Now when you start iisexpress.exe you should see a message such as

    Successfully registered URL "http://*:8080/" for site "hello world" application "/"

    0 讨论(0)
提交回复
热议问题