Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在IIS Express中启用外部请求?_C#_Asp.net_Iis Express - Fatal编程技术网

C# 如何在IIS Express中启用外部请求?

C# 如何在IIS Express中启用外部请求?,c#,asp.net,iis-express,C#,Asp.net,Iis Express,如何在IIS Express中启用远程请求?但是他没有说怎么做。现在IIS团队网站上有一篇博客文章解释了如何做。以下是该帖子的相关部分: 在Vista和Win7上,从管理提示符运行以下命令: netsh http添加urlacl url=http://vaidesg:8080/ 用户=所有人 对于XP,首先安装Windows XP Service Pack 2支持工具。然后在管理提示下运行以下命令: httpcfg设置urlacl/uhttp://vaidesg1:8080/ /ADD:(a;;

如何在IIS Express中启用远程请求?但是他没有说怎么做。

现在IIS团队网站上有一篇博客文章解释了如何做。以下是该帖子的相关部分:

在Vista和Win7上,从管理提示符运行以下命令:

netsh http添加urlacl url=http://vaidesg:8080/ 用户=所有人

对于XP,首先安装Windows XP Service Pack 2支持工具。然后在管理提示下运行以下命令:

httpcfg设置urlacl/uhttp://vaidesg1:8080/ /ADD:(a;;GX;;;WD)


这个问题的公认答案是让IIS Express使用webmatrix的指南。我发现在VS2010上使用它更有用

我只是按照第3步和第4步(以管理员身份运行IIS Express)进行操作,不得不临时禁用防火墙以使其正常工作。

Scott Hanselman提供了一个很好的资源


您所关注的是让IIS Express通过端口80从外部提供服务一节。您可能需要进行三项更改

  • 告诉IIS Express自身绑定到所有ip地址和主机名。在
    .config
    文件中。通常:
    • 与2015年相比:
      $(solutionDir)\.vs\config\applicationhost.config
    • %userprofile%\My Documents\IISExpress\config\applicationhost.config
  • 找到站点的绑定元素,然后添加

    
    
  • 设置名为“http.sys”的窗口位。以管理员身份运行以下命令:
  • netsh http add urlacl url=http://*:8080/user=everyone
    
    其中,
    每个人
    都是windows组。对带有空格的组使用双引号,如“Tout le monde”

  • 允许IIS Express通过Windows防火墙

    使用高级安全/入站规则/新规则启动/Windows防火墙

    程序
    %ProgramFiles%\IIS Express\iisexpress.exe

    或端口8080TCP

  • 现在,当您启动
    iisexpress.exe
    时,您应该会看到如下消息

    已成功注册网站“hello world”应用程序“/”的URL“http://*:8080/”

    作为对此的旁注:

    netsh http add urlacl url=http://vaidesg:8080/ user=everyone
    
    这仅适用于英文版本的Windows。如果您使用的是本地化版本,则必须用其他内容替换“everyone”,例如:

    • 使用荷兰语版本时使用“Iedereen”
    • 使用德语版本时使用“Jeder”
    • 使用匈牙利语版本时使用“Mindenki”

    否则会出现错误(创建SDDL失败,错误:1332)

    我在Win 8.1和外部请求中使用IIS Express时遇到一些问题

    我按照以下步骤调试外部请求:

  • 安装IIS
  • 将Visual Studio配置为使用本地IIS(Web项目中的页面属性)
  • 在IIS中创建专用应用程序池以使用我的应用程序
  • 在我的项目中,我使用的是Oracle客户端,必须是32位(64位不适用于Visual Studio),然后我需要在应用程序池中允许32位
  • 配置Windows防火墙以允许端口80中的请求(入站规则)

  • 它起作用了

    我无法向本地网络中的其他用户提供iis请求,我所要做的(除上述之外)就是重新启动我的BT集线器路由器。

    我记得几个月前尝试此工作流时遇到了相同的问题

    这就是为什么我专门为这种场景编写了一个简单的代理实用程序:

    使用,一切变得非常简单–无需“netsh http add urlacl url=vaidesg:8080/user=everyone”或搞乱“applicationhost.config”

    只需在命令提示符下发出以下命令:

    iisexpress代理8080到3000

    …然后您可以将远程设备指向

    大多数情况下,越简单越好。

    如果您尝试过但在Visual Studio中无法工作,请尝试以下方法:

    在IIS Express配置中附加另一个

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

    最后,您必须以管理员身份运行Visual Studio

    这真是太棒了,甚至还用漂亮的域名覆盖了HTTPS:

    我在其他任何地方都找不到真正棒的部分,所以万一上面的链接消失了:

    > C:\Program Files (x86)\IIS Express>IisExpressAdminCmd.exe Usage:
    > iisexpressadmincmd.exe <command> <parameters> Supported commands:
    >       setupFriendlyHostnameUrl -url:<url>
    >       deleteFriendlyHostnameUrl -url:<url>
    >       setupUrl -url:<url>
    >       deleteUrl -url:<url>
    >       setupSslUrl -url:<url> -CertHash:<value>
    >       setupSslUrl -url:<url> -UseSelfSigned
    >       deleteSslUrl -url:<url>
    > 
    > Examples: 1) Configure "http.sys" and "hosts" file for friendly
    > hostname "contoso": iisexpressadmincmd setupFriendlyHostnameUrl
    > -url:http://contoso:80/ 2) Remove "http.sys" configuration and "hosts" file entry for the friendly  hostname "contoso": iisexpressadmincmd
    > deleteFriendlyHostnameUrl -url:http://contoso:80/
    

    Certhash是您可以从MMC中的证书属性中获得的“指纹”。

    在我找到之前,任何东西对我都不起作用

    以管理员身份打开命令提示符,然后运行

    npm install -g iisexpress-proxy
    
    然后

    假设您的Visual Studio项目在localhost:51123上打开,并且您希望在外部IP地址x.x.x.x:81上访问


    编辑:我当前使用的是
    ngrok

    我启用了本地IIS,所以我刚刚创建了一个对调试端口的重写规则。。。我认为这比其他方法更好更酷,因为一旦完成开发,就更容易删除。。。下面是重写的样子

    <rewrite>
        <rules>
            <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                <match url="^dev/(.*)" />
                <action type="Rewrite" url="http://localhost:47039/{R:1}" />
            </rule>
        </rules>
    </rewrite>
    
    
    

    VS还允许您直接使用本地IIS进行开发(然后允许远程连接),但反过来,您必须始终以管理员身份运行它。。。我不喜欢这样。

    我做了以下操作并能够连接:

    1) 已将IIS express配置绑定从本地主机更改为“*”

    绑定协议=“http”bindingInformation=“*:8888:*”

    2) 已在防火墙上定义入站规则,以允许协议类型的特定端口:tcp

    3) 添加以下命令以添加端口的网络配置:
    netsh http add urlacl url=http://*:8888/user=everyone

    我使用反向代理方法解决了这个问题

    我安装了wamp服务器,并使用了ApacheWeb服务器的简单反向代理功能

    我添加了一个新端口来监听ApacheWeb服务器(8081)。然后,我添加了代理配置作为该端口的virtualhost

    <VirtualHost *:8081>
    ProxyPass / http://localhost:46935/
    ProxyPassReverse / http://localhost:46935/
    </VirtualHost>
    
    
    ProxyPass/http://localhost:46935/
    ProxyPassReverse/http://localhost:46935/
    
    <rewrite>
        <rules>
            <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                <match url="^dev/(.*)" />
                <action type="Rewrite" url="http://localhost:47039/{R:1}" />
            </rule>
        </rules>
    </rewrite>
    
    <VirtualHost *:8081>
    ProxyPass / http://localhost:46935/
    ProxyPassReverse / http://localhost:46935/
    </VirtualHost>
    
    <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>
    
    <binding protocol="http" bindingInformation="*:12345:192.168.1.15" />
    <binding protocol="https" bindingInformation="*:44300:192.168.1.15" />
    
    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
    
    %userprofile%\My Documents\IISExpress\config\applicationhost.config
    
    $(SolutionDir)\.vs\config\applicationHost.config
    
    <site name="WebApplication3" id="2">
       <application path="/" applicationPool="Clr4IntegratedAppPool">
          <virtualDirectory path="/" physicalPath="C:\Users\user.name\Source\Repos\protoype-one\WebApplication3" />
       </application>
       <bindings>
         <binding protocol="http" bindingInformation="*:62549:localhost" />
       </bindings>
    </site>
    
    ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
    ngrok http -host-header=localhost 89230