I'm trying to make a POST but every time returns an error saying
"The remote server returned an error: NotFound."
I'm using Firebug extension of Firefox to get all the necessary parameters of the POST method but firebug says
"... Firebug request size limit has been reached by Firebug. ..."
. Also wireshark says more or less the same thing.
I don't know if I need to specify (on windows phone 7 HttpWebRequest) some extra parameters on header because of the long POST method.
This is my code:
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);
});
}
}
Thanks in advance!