2016-12-21 69 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文件以匹配你的回答时,也发生了同样的情况。 : - \ –

相关问题