0
Web API在IIS中運行。我正在使用CLI來運行角度項目。 Http post兩次使用Web API方法。 首次web API參數爲空。第二次使用參數。角度4中的雙後期問題
API
[System.Web.Http.Route("api/Location/AddNewLocationSection")]
[HttpPost]
[AcceptVerbs("OPTIONS")]
public GenericResult AddNewCustomerLocationSection(GenericParam<CustomerLocationSectionTreeItem> locationSectionParam)
{
//due to double post i'm doing this check
if (locationSectionParam != null && locationSectionParam.Parameter != null)
{
//logic
}
}
角服務
addNewLocationSection(locationSectionDetails: CustomerLocationSectionInfo): Observable<any> {
var headers = new Headers();
headers.append('Content-Type', 'application/json');
return this.http.post(this._configuration.AddNewLocation JSON.stringify({ parameter: locationSectionDetails }), new RequestOptions({ headers: headers }))
.map(this.extractData)
.catch(this.handleError);
}
組件
this.locationDetailService.addNewLocationSection(this.locationSectionDetails)
.subscribe(success => this.reLoadCustomerLocationTree(success, "Add"),
error => this.errorMessage = <any>error);
我怎樣才能避免這種雙重職務。提前致謝。
所以它意味着使用選項我不能阻止這個? –
是的,這就是我的想法 – trichetriche