Have the following code (posted below), I this machine VS debug and IIS erection test can receive data (native IIS7.5), but the POST request is sent to the server or receiving data, the service side iis6.0, using WebClient service side with the test data can be received
Console main code:
Private static async TaskSendRequestEx (url string, int eventIndex, string carNum, long sn, int recordType, string doorNum,
Int inOrOut, int valid, string eventDate, string des, string photoName, string Token)
{
//HttpClient client=new HttpClient {BaseAddress=new Uri (url)};
Using (HttpClient client=new HttpClient ())
{
//HttpClient client=new HttpClient ();
Client. MaxResponseContentBufferSize=256000;
Client. DefaultRequestHeaders. Add (" the user-agent, "
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 ");
Using (MultipartFormDataContent content=new MultipartFormDataContent (DateTime. Now. The Ticks. ToString (" X ")))
{
Content. The Add (new StringContent (Convert. ToString (eventIndex)), "event_index");
Content. The Add (new StringContent (carNum), "card_num");
Content. The Add (new StringContent (Convert. ToString (sn)), "machine_sn");
Content. The Add (new StringContent (Convert. ToString (recordType)), "record_type");
Content. The Add (new StringContent (doorNum), "door_num");
Content. The Add (new StringContent (Convert. ToString (inOrOut)), "in_or_out");
Content. The Add (new StringContent (Convert. ToString (valid)), "is_valid");
Content. The Add (new StringContent (Convert. ToString (eventDate)), "event_date");
Content. The Add (new StringContent (Convert. ToString (des)), "event_des");
Content. The Add (new StringContent (Convert. ToString (photoName)), "photo");
Content. The Add (new StringContent (Convert. ToString (Token)), "Token");
Var response=await client. PostAsync (url, content);
Return the response. The content. ReadAsStringAsync (). The Result;
}
}
}
The server receives the code is as follows:
String eventIndex=context. Request [" event_index "];
String cardNum=context. Request [" card_num "];
String machineSn=context. Request [" machine_sn "];
String recordType=context. Request [" record_type "];
String doorNum=context. Request [" door_num "];
String inOrOut=context. Request [" in_or_out "];
String isValid=context. Request [" is_valid "];
String eventDate=context. The Request (" event_date ");
String eventDes=context. Request [" event_des "];
String token=context. The Request (" token ");
String photo=null;
Javis. WriteLog (" the Form - Data: [event_index] : "+ eventIndex +";" +
"[card_num] :" + cardNum + ";" +
"[machine_sn] :" + machineSn + ";" +
"[record_type] :" + recordType + ";" +
"[door_num] :" + doorNum + ";" +
"[in_or_out] :" + inOrOut + ";" +
"[is_valid] :" + isValid + ";" +
"[event_date] :" + eventDate + ";" +
"[event_des] :" + eventDes + ";" +
"[token] :" + token + ";" );
If (string. IsNullOrEmpty (eventIndex) | |
String. IsNullOrEmpty (cardNum) | |
String. IsNullOrEmpty (machineSn) | |
String. IsNullOrEmpty (recordType) | |
String. IsNullOrEmpty (doorNum) | |
String. IsNullOrEmpty (inOrOut) | |
String. IsNullOrEmpty isValid () | |
String. IsNullOrEmpty (eventDate) | |
String. IsNullOrEmpty (eventDes) | |
String. IsNullOrEmpty (token))
{
The context. The Response. The Write (" data "illegal);
return;
}
//here database insert
Print log has been empty, I don't know for what reason, trouble, can you help me to look at
CodePudding user response:
Try ~ in another wayCodePudding user response: