public async Task <IActionResult> Create([Bind] VisaForm visaForm) { if (ModelState.IsValid) { //第一次访问 Get var uri = "book_appointment.php"; var cookie = string.Empty; var responseCookie = await _httpFactory.HttpGet(uri, cookie); //第二次访问 Post 提交第一个表格 cookie = responseCookie; var param = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("app_type", visaForm.app_type), new KeyValuePair <string, string>("centre ", visaForm.centre), new KeyValuePair <string, string>("category", visaForm.category), new KeyValuePair <string, string>("phone_code", visaForm.phone_code), new KeyValuePair <string, string>("phone", visaForm.phone), new KeyValuePair <string, string>("email", visaForm.email), new KeyValuePair <string, string>("countryID", ""), new KeyValuePair <string, string>("member", visaForm.member), new KeyValuePair <string, string>("save", "Continue"), }; responseCookie = await _httpFactory.HttpPost(uri, cookie, param); //第三次访问 post 同意界面 获取cookie cookie = responseCookie; param = new List <KeyValuePair <string, string> >(); param.Add(new KeyValuePair <string, string>("agree", "Agree")); responseCookie = await _httpFactory.HttpPost(uri, cookie, param); //第四次访问 Get 获取详细表格申请的Cookie cookie = responseCookie; uri = "appointment.php"; responseCookie = await _httpFactory.HttpGet(uri, cookie); //第五次访问 Post 提交详细表格 cookie = responseCookie; param = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>(nameof(visaForm.app_date), visaForm.app_date.ToShortDateString()), new KeyValuePair <string, string>("app_date_hidden ", visaForm.app_date.ToShortDateString()), new KeyValuePair <string, string>("app_time", visaForm.app_time), new KeyValuePair <string, string>("captcha", visaForm.captcha), new KeyValuePair <string, string>("countryID", visaForm.countryID), new KeyValuePair <string, string>("dateOfBirth", visaForm.dateOfBirth.ToShortDateString()), new KeyValuePair <string, string>("first_name", visaForm.first_name), new KeyValuePair <string, string>("last_name", visaForm.last_name), new KeyValuePair <string, string>("loc_final", visaForm.loc_final), new KeyValuePair <string, string>("loc_selected", visaForm.loc_selected), new KeyValuePair <string, string>("mission_selected", visaForm.mission_selected), new KeyValuePair <string, string>("missionId", visaForm.missionId), new KeyValuePair <string, string>("nationalityId", visaForm.nationalityId), new KeyValuePair <string, string>("passport_no", visaForm.passport_no), new KeyValuePair <string, string>("passportType", visaForm.passportType), new KeyValuePair <string, string>("phone", visaForm.phone), new KeyValuePair <string, string>("phone_code", visaForm.phone_code), new KeyValuePair <string, string>("pptExpiryDate", visaForm.pptExpiryDate.ToShortDateString()), new KeyValuePair <string, string>("pptIssueDate", visaForm.pptIssueDate.ToShortDateString()), new KeyValuePair <string, string>("pptIssuePalace", visaForm.pptIssuePalace), new KeyValuePair <string, string>("save", "Submit"), new KeyValuePair <string, string>("VisaTypeId", "93"), }; responseCookie = await _httpFactory.HttpPost(uri, cookie, param); //第六次访问 Get 获取详细表格 cookie = responseCookie; uri = "message.php"; responseCookie = await _httpFactory.HttpGet(uri, cookie); _context.Add(visaForm); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(visaForm)); }