Asp.net-Mvc

啟用 SSL 時,IIS Express 預設使用 HTTPS 埠 44300

  • September 11, 2010

當您最初設置 IIS Express 以啟用 SSL 時,它預設埠為 44300。不幸的是,當我嘗試訪問我的站點時,https://localhost/它不起作用,除非我使用埠號 44300 - https://localhost:44300/

連結是使用以下內容生成的:

<%= Html.ActionLink("Index", "Index", "Home", new { @action = "https://" + Request.Hostname + Url.Action("Index", "Home") }) %>

雖然是一個醜陋的解決方案,@action關鍵字可以覆蓋生成的路由,但這意味著應用程序似乎需要知道任何非標準埠(例如 44300)。

問題是我會寫一些東西來解決一個只會在開發環境中出現的問題。

所以我的問題是……如何將埠更改為 443 並讓 IIS Express 喜歡它?

我的網站的配置如下:

<site name="MySite" id="2" serverAutoStart="true">
 <application path="/">
   <virtualDirectory path="/" physicalPath="C:\Inetpub\MySite" />
 </application>
 <bindings>
   <binding protocol="http" bindingInformation=":80:" />
   <binding protocol="https" bindingInformation=":44300:" />
 </bindings>
</site>

提前謝謝了。

更新:

Divya 在 IIS 論壇上已經回答了這個問題。

Divya 在 IIS 論壇上已經回答了這個問題。

在 WebMatrix 中為網站啟用 SSL 後,它預設為埠 44300 並在後台執行所有綁定。我希望您嘗試在配置文件中將此埠更改為 443。完成並保存後,您還需要修改 http.sys 中的綁定。您需要刪除埠 44300 的現有條目並添加埠 443 的條目。為此,您可以使用 httpcfg (WinXp/Win2003) 或“netsh http” (WinVista/Win2K8/Win7)。以下是 netsh 的命令:

  1. 獲取現有條目 44300 的 appid 和 certash(我假設,您將使用 WebMatrix 預設安裝的相同證書。如果您也想更改證書,請從證書儲存)netsh http show sslcert:。在輸出中搜尋埠 44300 的條目並複制 certhash 和 appID。

  2. 刪除 44300 的條目:netsh http delete sslcert ipport=0.0.0.0:44300

  3. 為埠 443 添加一個新條目,其中包含在步驟 1 中複製的 certash 和 appID。netsh http add sslcert ipport=0.0.0.0:443 certhash=<certhash> appid=<appid>

在 http.sys 中配置條目後,需要重新啟動 http 服務才能使更改生效。

net stop http

net start http

正如其他人所指出的,有幾種獲得 SSL 證書的好方法。

netsh http show sslcert > output.txt

或(我的首選方法):

netsh http show sslcert | clip

引用自:https://stackoverflow.com/questions/3690901