ISAPI extension cause ASP.net no redirect in server2008RSS

0 replies

Last post Sep 22, 2015 06:56 AM by beikezcs

  • ISAPI extension cause ASP.net no redirect in server2008

    Sep 22, 2015 06:56 AM|beikezcs|LINK

    I have a simple ISAPI extension, the HttpExtensionProc proc code below

    DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB)
    {
        HSE_EXEC_UNICODE_URL_INFO *pHseExecUrlInfo = new HSE_EXEC_UNICODE_URL_INFO();
    
        if (NULL == pHseExecUrlInfo)
        {
            return HSE_STATUS_ERROR;
        }
        else
        {
            ZeroMemory(pHseExecUrlInfo, sizeof(HSE_EXEC_UNICODE_URL_INFO));
            pHseExecUrlInfo->dwExecUrlFlags =  HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR; //prevent infinite loo
    
            if (!pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_IO_COMPLETION, ExecuteUrlCompletionCallback , NULL, (LPDWORD)pHseExecUrlInfo))
            {
                delete pHseExecUrlInfo;
                return HSE_STATUS_ERROR;
            }
            else
            {
                if (pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_EXEC_UNICODE_URL, pHseExecUrlInfo, NULL, NULL))
                {
                    return HSE_STATUS_PENDING;
                }
                else
                {
                    return HSE_STATUS_ERROR;
                }
            }
        }
    }


    ExecuteUrlCompletionCallback code below:

    VOID WINAPI ExecuteUrlCompletionCallback(LPEXTENSION_CONTROL_BLOCK lpECB, PVOID pContext, DWORD cbIO, DWORD dwError)
    {
        try
        {
            if (pContext != NULL)
            {
                HSE_EXEC_URL_STATUS hseExecUrlStatus;
                HSE_EXEC_UNICODE_URL_INFO *pHseExecUrlInfo = (HSE_EXEC_UNICODE_URL_INFO *)pContext;
    
                //
                // Set HTTP Status code on ISAPI so that logging works properly
                // cbIO and dwError should always be 0
                //
                if (!lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_GET_EXEC_URL_STATUS, &hseExecUrlStatus, NULL, NULL))
                {
                    //
                    // Was not able to fetch the HTTP Status codes.  Won't log any ISAPI failures for this
                    //
                }
                else
                {
                    //
                    // Must set lpECB->dwHttpStatusCode or else logging is incorrectly always 200
                    // Should propagate hseExecUrlStatus.dwWin32Error if I don't do anything about it
                    //
                    lpECB->dwHttpStatusCode = hseExecUrlStatus.uHttpStatusCode;
                    SetLastError( hseExecUrlStatus.dwWin32Error );
                }
    
                DWORD dwStatusType = HSE_STATUS_SUCCESS;//HSE_STATUS_SUCCESS;
                //
                lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_DONE_WITH_SESSION, &dwStatusType, NULL, NULL);
                delete pHseExecUrlInfo;
            }
        }
        catch (...)
        {
            //do nothing
        }
    }


    I have a simple asp.net example,whick have 2 page,index.aspx,get.aspx,in index.aspx, click button will redirect to get.aspx,some code like this:

       protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("get.aspx");
        }


    I find if i call HttpContext.Current.Request.Form in Application_BeginRequest,when i click the button in index.aspx,the page not redirect, and still stay in index.aspx,code


      protected void Application_BeginRequest(object sender, EventArgs e)
        {
            if (Request.RequestType.ToUpper() == "POST")
            {
                 HttpContext.Current.Request.Form;
            }
        }


    without HttpContext.Current.Request.Form; everything is ok.. this just happen in server2008, sever2003,all is ok..

    do someone know why or happend to ever face samep problem?

    with debug, found that pECB->cbAvailable != pECB->cbTotalBytes.Then I use ReadClient,but failed with 10054.