配合asp.net快速使用ngrok
最近常常需要透過ngrok來偵錯WebHook或WebAPI,前面曾經介紹過,當你下載了該工具之後,可以在DOS prompt下一個類似底下這樣的簡單指令來讓你的localhost網站能夠被外界讀取:
ngrok http 31217 -host-header="localhost:31217"
執行後你會看到類似底下的畫面:
這表示,上面這樣的指令已經可以讓ngrok把你的 http://localhost:31217 對應到 http://c5bfcbb9.ngrok.io
這樣的動作做久了之後,常常打command line不免覺得很煩,所以乾脆寫一個簡單的batch file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rem 讓用戶輸入 port變數 | |
set /p port="input port: " | |
rem 切換到你的ngrok資料夾(請自行調整) | |
path "C:\ngrok" | |
rem 直接將port NO.帶入執行ngrok | |
ngrok http %port% -host-header="localhost:%port%" |
透過然後把上面這個簡單的batch file放在桌面上(或是其他你順手的位置),需要ngrok為你服務時,只需要執行它:
輸入五位數的port NO.之後,就會自動運行ngrok囉…
hope it helps.
留言