How to enable external request in IIS Express?

前端 未结 26 1177
借酒劲吻你
借酒劲吻你 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:53

    This is insanely awesome and even covers HTTPS with pretty domain names:

    http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx

    The really awesome parts I couldn't find anywhere else on SO in case the above link ever goes away:

    > C:\Program Files (x86)\IIS Express>IisExpressAdminCmd.exe Usage:
    > iisexpressadmincmd.exe   Supported commands:
    >       setupFriendlyHostnameUrl -url:
    >       deleteFriendlyHostnameUrl -url:
    >       setupUrl -url:
    >       deleteUrl -url:
    >       setupSslUrl -url: -CertHash:
    >       setupSslUrl -url: -UseSelfSigned
    >       deleteSslUrl -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/
    

    The above utility will register the SSL certificate for you! If you use the -UseSelfSigned option, it's super easy.

    If you want to do things the hard way, the non-obvious part is you need to tell HTTP.SYS what certificate to use, like this:

    netsh http add sslcert ipport=0.0.0.0:443 appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash=YOURCERTHASHHERE
    

    Certhash is the "Thumbprint" you can get from the certificate properties in MMC.

提交回复
热议问题