【发布时间】:2015-12-05 06:49:31
【问题描述】:
我现在正在通过以下方式发送请求。
在 PROD 中(托管在本地 IIS 服务器中)-
this.post = function (Prescription) {
var request = $http({
method: "post",
dataType: "json",
url: "/SmileMakersApp/SmileMakersApp/api/PrescriptionsAPI",
data: Prescription
});
return request;
}
在开发中 -
this.post = function (Prescription) {
var request = $http({
method: "post",
dataType: "json",
url: "/api/PrescriptionsAPI",
data: Prescription
});
return request;
}
问题是我正在维护版本并定期通过 git 更新我的代码。因此,每当我对该文件进行新的更改时,我都必须每次都解决冲突。并且有许多类似的请求,并且为每个请求解决冲突很麻烦。有什么方法可以让我在 PROD 和 DEV 中定义不同的 url?我已经在后端做了类似的事情。
@if (HttpContext.Current.IsDebuggingEnabled)
{
<base href="/">
}
else
{
<base href="/SmileMakersApp/SmileMakersApp/">
}
【问题讨论】:
-
您可以在 Angular 中使用相同的基本 href 值:document.querySelector('head > base').getAttribute('href')。
标签: asp.net angularjs asp.net-web-api2