CHttpConnection和页面通讯,页面跳转,出现url重复的问题。
各位大侠,
我在做http登陆页面的功能,登陆成功后,页面跳转,
结果抓包发现,上次的页面登陆没有跳转
第一步:
登陆页面--》已经成功
CString strHost = _T("web.3324beet.com");
CString strUrl = _T("/Login?ReturnUrl=%2f");
CStringA strRequest = "UserName=daodao9&Password=aa123456&VerifyCode=";//提交的数据
strRequest += strVcode;
CString strHeader = _T("Content-Type: application/x-www-form-urlencoded\r\n");
pHttpConnection = m_SessionXiazhu.GetHttpConnection(strHost, m_Port);
if (pHttpConnection == NULL)
printf("CHttpConnection failed!");
m_pFile = pHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, strUrl);
if (m_pFile == NULL)
printf("CHttpFile is NULL!");
m_pFile->AddRequestHeaders(strHeader);
m_pFile->SendRequest(strHeader, (LPVOID)(LPCSTR)strRequest, strRequest.GetLength());
登陆返回值正确,第二步获取信息返回值不正确,抓包后发现URL错误,可是我的输入确实下面的情况:
为什么会出现,第二次链接请求,带上了上次的url,出现了这样的情况
url === /Login?ReturnUrl=/Heji/NextIssueNo
正确的应该是:/Heji/NextIssueNo才对;
第二步:
获取信息页面:
CString strHost = _T("web.3324beet.com");
CString strUrl = _T("/Heji/NextIssueNo");
CString strRequest = strTime;//提交的数据
CString strHeader = _T("Content-Type: application/x-www-form-urlencoded\r\n");
try
{
pHttpConnection = m_SessionXiazhu.GetHttpConnection(strHost, IntPort);
if (pHttpConnection == NULL)
printf("CHttpConnection failed!");
m_pFile = pHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET, strUrl);
if (m_pFile == NULL)
printf("CHttpFile is NULL!");
m_pFile->AddRequestHeaders(strHeader);
m_pFile->SendRequest(strHeader, 0,0);