运行 用户流程:localhost 拒绝连接
Running user flow: localhost refused to connect
我有一个 blazor 应用程序。我使用 Azure AD B2C 进行身份验证。当我尝试 运行 登录用户流程时,我得到
This site can’t be reached
localhost refused to connect.
这是我的 launchSettings.json:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:54925",
"sslPort": 44333
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MyAppName": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
来自appsettings.json:
"AzureAdB2C": {
"Instance": "https://laticreteb2c.b2clogin.com",
"ClientId": "Set in Azure. For development, set in User Secrets (secrets.json)",
"CallbackPath": "/signin-oidc",
"Domain": "laticreteb2c.onmicrosoft.com",
"SignOutCallbackPath": "/signout",
"SignUpSignInPolicyId": "B2C_1_MyAppName_SignIn",
"ResetPasswordPolicyId": "MyAppName_PasswordReset",
"EditProfilePolicyId": "",
"ClientSecret": "Set in Azure. For development, set in User Secrets (secrets.json)",
"TenantId": "Set in Azure. For development, set in User Secrets (secrets.json)"
},
我正在 运行我的用户流回复 url https://localhost:5001/signin-oidc.
我知道它以前在本地和生产环境中都可以工作,但我无法弄清楚从那以后可能会出现什么问题。我如何诊断此问题?
请检查以下见解是否有助于解决问题:
此异常 This site can’t be reached localhost refused to connect
通常发生在没有服务侦听您尝试连接的 IP/port 或尝试连接错误的 IP/port.[=19 时=]
- 尝试更改端口号
- 或者您甚至可以尝试用您的 IP 地址替换 localhost。
And also do ensure there's no firewall blocking the connection.and whatever port you change , make sure same is given in appregistration reply url.
"profiles": {
" MyAppName": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": https://localhost:44316/;http://localhost:3110 ,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
}
}
另请检查是否
- You have started your server.
- Your server is listening for connections or not.
- Try deleting cookies for your localhost
- Run Visual Studio as "Run as administrator"
- You have Granted admin consent for open id and offline access permissions in portal.
在应用程序设置中查看实例是否必须类似于:
"Instance": https://yourb2cdomain.b2clogin.com/tfp/
最后,如果问题仍然存在,请尝试找到 .vs 文件夹和 Obj 文件夹并删除它们,然后再次 运行。
参考文献:
- GitHub - JagadeshDev : Creating A Blazor Server Azure B2C App
- BlazorADB2C/BlazorADB2C at master · bdnts/BlazorADB2C · GitHub
- Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2 · GitHub
如果您觉得 asp.net 应用程序配置有问题,您可以尝试在此处检查可能导致错误的问题 > asp.net mvc - localhost refused to connect Error in visual studio - Stack Overflow
我有一个 blazor 应用程序。我使用 Azure AD B2C 进行身份验证。当我尝试 运行 登录用户流程时,我得到
This site can’t be reached
localhost refused to connect.
这是我的 launchSettings.json:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:54925",
"sslPort": 44333
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MyAppName": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
来自appsettings.json:
"AzureAdB2C": {
"Instance": "https://laticreteb2c.b2clogin.com",
"ClientId": "Set in Azure. For development, set in User Secrets (secrets.json)",
"CallbackPath": "/signin-oidc",
"Domain": "laticreteb2c.onmicrosoft.com",
"SignOutCallbackPath": "/signout",
"SignUpSignInPolicyId": "B2C_1_MyAppName_SignIn",
"ResetPasswordPolicyId": "MyAppName_PasswordReset",
"EditProfilePolicyId": "",
"ClientSecret": "Set in Azure. For development, set in User Secrets (secrets.json)",
"TenantId": "Set in Azure. For development, set in User Secrets (secrets.json)"
},
我正在 运行我的用户流回复 url https://localhost:5001/signin-oidc.
我知道它以前在本地和生产环境中都可以工作,但我无法弄清楚从那以后可能会出现什么问题。我如何诊断此问题?
请检查以下见解是否有助于解决问题:
此异常 This site can’t be reached localhost refused to connect
通常发生在没有服务侦听您尝试连接的 IP/port 或尝试连接错误的 IP/port.[=19 时=]
- 尝试更改端口号
- 或者您甚至可以尝试用您的 IP 地址替换 localhost。
And also do ensure there's no firewall blocking the connection.and whatever port you change , make sure same is given in appregistration reply url.
"profiles": {
" MyAppName": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": https://localhost:44316/;http://localhost:3110 ,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
}
}
另请检查是否
- You have started your server.
- Your server is listening for connections or not.
- Try deleting cookies for your localhost
- Run Visual Studio as "Run as administrator"
- You have Granted admin consent for open id and offline access permissions in portal.
在应用程序设置中查看实例是否必须类似于:
"Instance": https://yourb2cdomain.b2clogin.com/tfp/
最后,如果问题仍然存在,请尝试找到 .vs 文件夹和 Obj 文件夹并删除它们,然后再次 运行。
参考文献:
- GitHub - JagadeshDev : Creating A Blazor Server Azure B2C App
- BlazorADB2C/BlazorADB2C at master · bdnts/BlazorADB2C · GitHub
- Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2 · GitHub
如果您觉得 asp.net 应用程序配置有问题,您可以尝试在此处检查可能导致错误的问题 > asp.net mvc - localhost refused to connect Error in visual studio - Stack Overflow