2016-12-21 70 views
8

我正在關注this教程,以將Facebook身份驗證添加到我的Web應用程序中。在調試中爲SSL配置launchSettings.json - ASP.NET Core/Visual Studio代碼

作爲該過程的一部分,我試圖在我的項目上啓用SSL,但是我發現的所有內容都涉及更新Visual Studio中項目屬性對話框中的設置,該設置在我的Mac上無法通過Visual Studio代碼訪問。我試過手動更新launchSettings.json中的值,但我沒有任何運氣。

如何在Visual Studio代碼中更新launchSettings.json(或其他項目文件)以在調試時啓用SSL?

回答

2

我做了以下編輯launchStingSettings.json在Windows上,它沒有竅門。目前這是在Visual Studio 2017 RC中唯一的方法。

{ 
    "iisSettings": { 
    "windowsAuthentication": false, 
    "anonymousAuthentication": true, 
    "iisExpress": { 
     "applicationUrl": "http://localhost:50183/", 
     "sslPort": 44318 
    } 
    }, 
    "profiles": { 
    "IIS Express": { 
     "commandName": "IISExpress", 
     "launchBrowser": true, 
     "launchUrl": "https://localhost:44318", 
     "environmentVariables": { 
     "ASPNETCORE_ENVIRONMENT": "Development" 
     } 
    }, 
    "corePostgresIdentity": { 
     "commandName": "Project", 
     "launchBrowser": true, 
     "environmentVariables": { 
     "ASPNETCORE_ENVIRONMENT": "Development" 
     }, 
     "applicationUrl": "https://localhost:44318" 
    } 
    } 
} 
+0

我更新了我的launchSettings.json來匹配你的,但項目仍在啓動原來的端口是5000,而不是50183.上如果我把'的https://本地主機:44318'到地址欄中,我的瀏覽器說它無法連接到服務器。不知道它從哪裏得到5000,重新啓動VS Code沒有幫助。必須有一些我缺少的東西。 –

+0

我不確定,對不起。也許試着去看看https://docs.microsoft.com/en-us/aspnet/core/tutorials/your-first-mac-aspnet。此外,搜索解決方案中的所有文件「5000」,它必須在某處。 –

+0

對於將來可能有此問題的任何人 - 如果您還使用WebListener(https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/servers/weblistener),那麼它將偵聽端口5000並忽略您的launchSettings.json配置。 – jacobappleton

0

通常當您修改項目的屬性時,更改將持續在launchSettings.json中。所以,你需要改變launchSettings.json象下面這樣:

{ 
    "iisSettings": { 
    "windowsAuthentication": false, 
    "anonymousAuthentication": true, 
    "iisExpress": { 
     "applicationUrl": "http://localhost:8837/", 
     "sslPort": 0 //Add ssl port here 
    } 
    }, 
"profiles": { 
    "IIS Express": { 
     "commandName": "IISExpress", 
     "launchBrowser": true, 
     "launchUrl": "https://localhost:8837", 
     "environmentVariables": { 
     "ASPNETCORE_ENVIRONMENT": "Development" 
    } 
}, 
+0

查看我對Sam Sippe的回答的評論 - 當我更新launchSettings.json文件以匹配你的回答時,也發生了同樣的情況。 : - \ –

相關問題