使用API的不同端口启动设置



我的API项目设置:

"profiles": {
"LGSafetyAPI": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7295;http://localhost:5295",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}

}

MVC项目设置为:

"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:52964",
"sslPort": 44394
}

MVC项目提供了一个ajax调用来查找API。。。但由于url不同,它正在尝试查找

localhost:44394 instead of localhost:7295

如何根据环境更改这些设置?

我记得我用.net api项目处理过类似的setup-rect项目。。它似乎毫无效果。。但不知怎么的,这里看起来很难。

检查JQuery Ajax请求URL,尝试使用固定的请求URL,如下所示:

$.ajax({
type: "Get",
url: "https://localhost:7295/APIController/ActionName", 
success: function (response) {
console.log(response); 
},
error: function (xhr, textStatus, errorThrown) {
console.log('in error');
}
});

最新更新