Shashank5360

Hi all,

I am using CInternetSession, CHttpConnection and CHttpFile classes to fetch the asp page. The code seems to run fine for the first time, but it hangs on the second call. here is the code i wrote:-

Internet session is initialized in the constructor:-

m_pSession = new CInternetSession("CHttpHelper");

CHttpConnection* pServer = NULL;

CHttpFile* pFile = NULL;

CString server;

CString object;

INTERNET_PORT port;

DWORD a;

DWORD dwRet;

DWORD dwHttpRequestFlags =INTERNET_FLAG_DONT_CACHE;

CString Page;

char Buffer[512];

AfxParseURL(url, a, server, object, port);

pServer = m_pSession->GetHttpConnection(server, port);

pFile = pServer->OpenRequest(

CHttpConnection::HTTP_VERB_GET,

object,

NULL,

1,

NULL,

NULL,

dwHttpRequestFlags);

if(pFile != NULL)

{pFile->SendRequest();

pFile->QueryInfoStatusCode(dwRet);

if(dwRet == HTTP_STATUS_OK)

{

int nCount = 1;

while(nCount > 0)

{

// Read the Page in a String

nCount = pFile->Read(Buffer, 511);

if(nCount > 0)

{

Buffer[nCount] = 0;

Page += Buffer;

}

}

}

}

if(pFile != NULL)

{

pFile->Close();

delete(pFile);

pFile=NULL;

}

if(pServer != NULL)

{

pServer->Close();

delete(pServer);

pServer=NULL;

}

Thanks in advance.

Note:- 1. The code runs fine when i add an AfxMessageBox("Run"); before

pFile->SendRequest().

2. It works fine with local asp page.