POSTを作成しようとしていますが、毎回エラーが返されます。
「リモートサーバーがエラーを返しました:NotFound。」
FirefoxのFirebug拡張機能を使用して、POSTメソッドに必要なすべてのパラメーターを取得していますが、firebugは
「...FirebugがFirebugリクエストのサイズ制限に達しました。...」
。また、wiresharkは多かれ少なかれ同じことを言います。
POSTメソッドが長いため、ヘッダーにいくつかの追加パラメーターを指定する必要があるかどうかはわかりません(Windows Phone 7 HttpWebRequestの場合)。
これは私のコードです:
private void GetResponseCallbackAGCP(IAsyncResult asynchronousResult)
{
Uri url = new Uri("http://publico.agcp.ipleiria.pt/Paginas/ScheduleRptCursosSemanalPublico.aspx");
postData = "MSO_PageHashCode=" + _MSO_PageHashCode +
"&__SPSCEditMenu=" + ___SPSCEditMenu +
"&MSOWebPartPage_PostbackSource=" +
"&MSOTlPn_SelectedWpId=" +
"&MSOTlPn_View=0" +
"&MSOTlPn_ShowSettings=" + _MSOTlPn_ShowSettings +
"&MSOGallery_SelectedLibrary=" +
"&MSOGallery_FilterString=" +
"&MSOTlPn_Button=" + _MSOTlPn_Button +
"&MSOAuthoringConsole_FormContext=" +
"&MSOAC_EditDuringWorkflow=" +
"&MSOSPWebPartManager_DisplayModeName=" + _MSOSPWebPartManager_DisplayModeName +
"&__EVENTTARGET=" + _eventTarget +
"&__EVENTARGUMENT=" + _eventArg +
"&MSOWebPartPage_Shared=" +
"&MSOLayout_LayoutChanges=" +
"&MSOLayout_InDesignMode=" +
"&MSOSPWebPartManager_OldDisplayModeName=" + _MSOSPWebPartManager_OldDisplayModeName +
"&MSOSPWebPartManager_StartWebPartEditingName=" + _MSOSPWebPartManager_StartWebPartEditingName +
"&__LASTFOCUS=" +
"&__REQUESTDIGEST=" + ___REQUESTDIGEST +
"&__VIEWSTATE=" + _viewState +
"&__EVENTVALIDATION=" + _eventEval +
"&ctl00%24ctl12%24ctl00=http%3A%2F%2Fspserver%3A7250" +
"&ctl00%24PlaceHolderAGCPUO%24ddlUO=" + escolaSelected +
"&ctl00%24PlaceHolderAGCPUO%24ddlAnosLectivos=" + anoLectivoSelected +
"&ctl00%24PlaceHolderAGCPUO%24ddlPeriodos=" + periodoSelected +
"&ctl00%24PlaceHolderMain%24ddlCursos=" + cursoSelected +
"&ctl00%24PlaceHolderMain%24ddlAnosCurr=" + anoCurricularSelected +
"&ctl00%24PlaceHolderMain%24ddlPlanos=" + planoSelected +
"&ctl00%24PlaceHolderMain%24ddlRamos=" + troncoSelected +
"&ctl00%24PlaceHolderMain%24ddlTurmas=" + turmaSelected +
"&ctl00%24PlaceHolderMain%24txtObservacoesHor=" +
"&ctl00%24PlaceHolderMain%24ddlZoom=1250" +
"&ctl00%24PlaceHolderMain%24ddlSemanas=" + semanaSelected +
"&ctl00_PlaceHolderMain_DayPilotCalendar1_vsupdate=" +
"&ctl00_PlaceHolderMain_DayPilotCalendar1_scrollpos=" +
"&ctl00_PlaceHolderMain_DayPilotCalendar1_select=" +
"&__spDummyText1=__spDummyText1&__spDummyText2=__spDummyText2";
cc = new CookieContainer();
webRequest2 = (HttpWebRequest)WebRequest.Create(url);
webRequest2.Method = "POST";
webRequest2.ContentType = "application/x-www-form-urlencoded";
webRequest2.CookieContainer = cc;
webRequest2.BeginGetRequestStream(new AsyncCallback(GetRequestCallback), webRequest2);
}
private void GetRequestCallback(IAsyncResult asynchronousResult)
{
var request = asynchronousResult.AsyncState as HttpWebRequest;
StreamWriter stream = new StreamWriter(request.EndGetRequestStream(asynchronousResult));
stream.Write(postData);
stream.Flush();
stream.Close();
request.BeginGetResponse(AuthCallback, request);
}
private void AuthCallback(IAsyncResult asyncResult)
{
HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult); //RETURNS an error saying "WebException was unhandle. The remote server returned an error: NotFound."
using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream()))
{
//string resultString = streamReader1.ReadToEnd();
var info = streamReader1.ReadToEnd();
System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
{
webView.NavigateToString(info);
});
}
}
前もって感謝します!