问题
I have a angular application which works fine locally, but when published it on a test server it doesn't work any more some of my POST requests returns a 400 - bad request, and some don't, I have no idea why this is working locally but once published it doesn't.
What I have tried:
►I am sure the test server has access to the database I'm connecting to since, previous versions of the application worked on it and other as well that uses the same database.
►I logged all my objects that I'm sending to the API to check if there is something missing or wrong data going through but it all looks the same locally and when published.
►I'm definitely sure this is not a cors error as I'm not getting any of those types of errors.
MY web.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\pamcportal.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
One of the POST that I,m making (typscript side)
GetListOfPaidBatches() {
console.log("get paid batches: ", this.amounts);
this.showList = true;
this.showBordRowComponents = false;
this._paidBatches = [];
this._http.post(this._baseUrl + 'api/CheckRun/GetPaidBatches',
this.amounts
).subscribe((recievedList: CheckRunTypeModel[]) => {
let v = recievedList;
this._paidBatchesType = v;
this._paidBatchesType.forEach((pb) => {
let key2: string = pb.batchNo.substr(0, 6);
let contains: boolean = this._filteredPaidList.some(y => y.yearMont === key2);
if (contains) {
this._filteredPaidList.forEach((fl) => {
if (fl.yearMont === key2) {
let include = fl.list.some(y => y === pb);
if (include === false) {
fl.list.push(pb);
}
}
});
} else {
let d: CheckRunTypeModel[] = [];
d.push(pb);
this._filteredPaidList.push({
yearMont: key2,
list: d
});
}
});
this._paid = {};
this._filteredPaidList.forEach((flp) => {
let batchNumbers = flp.list;
let indexer = flp.yearMont;
this._paid[indexer] = batchNumbers
});
},
(error) => {
console.log(error);
},
() => {
this.showBordRowComponents = true;
this.CheckCheckRunTypeArrayPaid(this._paidBatchesType);
this.GetUnreleasedBatches()
});
}
and the method its calling in the API
[HttpPost]
[Route("GetPaidBatches")]
public List<CheckRunTypeModel> GetPaidBatches([FromBody] ClaimsModel data)
{
CheckRunTypeModel detailedBatch = new CheckRunTypeModel();
DataTable datatbl = new DataTable();
List<CheckRunTypeModel> returnList = new List<CheckRunTypeModel>();
DataTable dtable = new DataTable();
List<string> paidList = new List<string>();
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand();
SqlConnection cn = new SqlConnection();
string claimNo = "";
cmd.CommandTimeout = 300;
cn.ConnectionString = _portalConnection;
if (cn.State != ConnectionState.Open)
{
cn.Open();
}
string batchNo = "";
string clientName = "";
string description = "";
string hpcode = "";
try
{
}
catch (Exception e)
{
var msg = e.Message;
}
}
}
catch (Exception e)
{
var msg = e.Message;
}
return returnList;
}
Can anyone tell me why this is not working when I publish the application on 'IIS' but locally it works.
来源:https://stackoverflow.com/questions/56524740/i-get-a-400-bad-request-when-i-published-my-application-on-iis-but-before-p