【发布时间】:2021-04-04 09:20:23
【问题描述】:
我是 .net 的新手,我的 Web 应用程序运行良好,问题是我想从 Ip Address 而不是 localhost 打开它,以便 LAN 上的每个人都可以访问它。我在launchsetting.json 中将localhost 替换为IP,它使用IP 打开Web 应用程序,但是它不会连接到Database,但是当我使用localhost 打开它时,它可以与Database 一起正常工作。非常感谢任何帮助。
数据库:SQLEXPRESS 18。
这是我的launchsetting.json 文件:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51911",
"sslPort": 44374
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ReactC_MDSS": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
这是我的 DB 连接字符串的 appsetting.json 文件:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"patientDB": "Data Source=DESKTOP-FE7Q19U\\SQLEXPRESS;Initial Catalog=MDSS;Integrated Security=True"
}
}
【问题讨论】:
-
这没有意义,启动 url 应该是 localhost,因为您的构建部署在 localhost 中。如果您想在 LAN 中构建一个演示服务器供其他开发人员访问它,只需转到主机(其 IP 就是您想要的)并在那里部署您的构建(不需要更改启动 url,只需注意应该打开的端口)。这可能还需要安装数据库服务器(或相应地调整您的 sql 连接字符串)。
-
嗨@wraith123 456,你可以看到这个thread可能有帮助。
标签: sql asp.net asp.net-core sql-server-express