|
-
April 30th, 2010, 11:05 AM
#1
Problem with Debugging ISAPI Extension on IIS 6.0 ...
Hello All,
I have written a small & Simple ISAPI extension that simply print "Hello" in the browser. The code that I used is below in the code section.
I wanted to Write to a file from the ISAPI extension. So I tried to set permissions of the folder to specify WRITE in addition to READ permission. This is done using the IIS Manager Snap-in. After calling the extension's DLL from the browser, I can see the Hello world in the browser and 200 status code in IIS W3C log file.
The only thing I can't see is the log file at C:\.
Code:
BOOL WINAPI DllMain(IN HINSTANCE hinstDll, IN DWORD dwReason, IN LPVOID lpvContext)
{
return TRUE;
}
BOOL WINAPI GetExtensionVersion(OUT HSE_VERSION_INFO *pVer)
{
const CHAR szExtensionInfo[] = "SGN: ISAPI Extension" ;
pVer->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR); // HSE_VERSION;
strncpy_s(pVer->lpszExtensionDesc, HSE_MAX_EXT_DLL_NAME_LEN, szExtensionInfo, strlen(szExtensionInfo));
return TRUE;
}
DWORD WINAPI HttpExtensionProc(IN EXTENSION_CONTROL_BLOCK *pECB)
{
static char szMessage[] = "<HTML><HEAD><TITLE> Hello World </TITLE></HEAD>\r\n"
"<BODY><H2>Hello from Simple ISAPI Extension DLL!</H2>\r\n</BODY></HTML>\r\n\r\n";
HSE_SEND_HEADER_EX_INFO HeaderExInfo;
HeaderExInfo.pszStatus = "200 OK";
HeaderExInfo.pszHeader = "Content-type: text/html\r\n\r\n";
HeaderExInfo.cchStatus = strlen(HeaderExInfo.pszStatus);
HeaderExInfo.cchHeader = strlen(HeaderExInfo.pszHeader);
HeaderExInfo.fKeepConn = FALSE;
pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &HeaderExInfo, NULL, NULL);
HANDLE hLogFile = CreateFile(TEXT("C:\\RequestLog.txt"), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL) ;
if (hLogFile != NULL && hLogFile != INVALID_HANDLE_VALUE)
{
DWORD dwWritten = 0 ;
SetFilePointer(hLogFile, 0, NULL, FILE_END) ;
if (WriteFile(hLogFile, szMessage, strlen(szMessage), &dwWritten, NULL) == FALSE)
{
// Write to Event Log then ... (if possible)
}
CloseHandle(hLogFile) ;
}
DWORD dwBytesToWrite = strlen( szMessage );
pECB->WriteClient( pECB->ConnID, szMessage, &dwBytesToWrite, 0 );
return HSE_STATUS_SUCCESS;
}
BOOL WINAPI TerminateExtension(IN DWORD dwFlags)
{
return TRUE;
}
I have a few questions in my mind after this:
- Can someone let me know, what can I do to troubleshoot the issue ? The machine with IIS has the MS VC Remote Debugger (MSVCMON.exe) installed there. However, After connecting to IIS, My Visual Studio 2008 freezes until Infinity.
- How do I debug and confirm that which functions are getting failed ?
- How do I log information from inside of my ISAPI extension ?
- Is it possible to log entries into Window Event Log from inside of my ISAPI extension ?
- What else permissions are required for my ISAPI extension to be able to write to file ?
I know, lots of questions but Your Answer would be of great help in clearing the clouds and will be appreciated.
Thanks,
(*Vipul)() ;
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|