이전에는 데이터 게시 및 응답 수신에 문제가 있었지만 마침내 데이터를 게시 할 수 있었지만 응답을 통해 올바른 결과를 얻을 수 없었습니다. webform을 실행 한 다음 Visual Studio로 코드를 실행하고 Fiddler를 사용하여 webform을 비교했습니다.이 코드는 내가 볼 수있는 것에서 제대로 채워졌습니다. 그런 다음 두 사이트의 결과를 비교하여 사이트를 통해 그리고 시각적 인 스튜디오를 통해 비교 한 결과 나는 만족할만한 결과를 얻지 못하고 왜 그런지, 그리고 지난 두 시간 동안 내가 잘못하고있다 (이전에 질문을 게시하고 내가하고 싶은 것에 대한 지침을 가졌으므로, 이전 사과와 같은 것을 보았다면 더 분명하게해야했다).게시 후 예상 응답 데이터가 나타나지 않습니다.
나는 썼다
public static string PostMyData()
{
// This is where the data is going to be posted
string url = @"http://www.cpso.on.ca/Public-Register/All-Doctors-Search.aspx";
// This is the data that i am going to post
string postData = "manScript_HiddenField=&" +
"__EVENTTARGET=p%24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24btnSubmit&" +
"__EVENTARGUMENT=&__LASTFOCUS=&lng=en-CA&p%24lt%24ctl00%24SearchBox%24txtWord=Site+Search&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24txtLastName=Aalders&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24txtFirstName=&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24grpGender=+&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24ddLanguage=08&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24grpDocType=rdoDocTypeAll&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24grpStatus=rdoStatusActive&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24ddCity=Select --%3E&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24txtPostalCode=&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24ddHospitalCity=Select+--%3E&p%" +
"24lt%24ctl03%24pageplaceholder%24p%24lt%24ctl03%24AllDoctorsSearch%24ddHospitalName=-1&" +
"__VIEWSTATE=";
// Create my request
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = postData.Length;
req.Referer = @"http://www.cpso.on.ca/Public-Register/All-Doctors-Search.aspx";
req.Accept = "text/html, application/xhtml+xml, */*";
req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko";
// Now its time to write the data that I want to post to the webpage
using (StreamWriter reqWriter = new StreamWriter(req.GetRequestStream()))
{
reqWriter.Write(postData);
}
// Get the response/results
string respData = string.Empty;
using (StreamReader responseReader = new StreamReader(req.GetResponse().GetResponseStream()))
{
// Add response/results to string
respData = responseReader.ReadToEnd();
}
return respData;
}
반환 respData에서 중단 점을 설정하고 하나의 레코드를 표시해야하지만 아무 것도 표시하지 않아야합니다. 여기
은 ... 하나는 실제 웹 양식을 통해가는 피들러에 표시된 웹 양식입니다찍어이며, 여기에 내가 비주얼 스튜디오를 통해 실행할 때 하나이며,이 도선이 있습니다 내게는이 같은
와우, 내가 없어진 모든이었다 한 조각 . 그걸 정리 해줘서 고마워. 또 다른 장점은 지금까지 ASP.NET에 대한 바이올린이 있다는 것을 몰랐다는 것입니다 :-) – Chris
예. 그것은 꽤 편리합니다. 당신이 이것으로 악을 행하지 않기를 바랍니다. :) –
나는 그것으로부터 뭔가 나쁜 것을 만들기 시작하는 곳을 알지조차 모른다. – Chris