判断链接过来某个文件夹下载文件的页面是不是xxx.asp,是的通过,不是的返回。请教如何写那?

解决方案 »

  1.   

    isapi现在很少有人写了。
      

  2.   

    look into 
    CHttpFilterContext::GetServerVariable for SCRIPT_NAME
    http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_CHttpFilterContext.3a3a.GetServerVariable.asp?frame=truealso check out
    ISAPI Extensions and Filters 
    http://www.iisfaq.com/default.asp?View=P11
      

  3.   

    读HTTP Header "Referer: "
      

  4.   

    // MYAPP.CPP - Implementation file for your Internet Server
    //    MyApp Extension#include "stdafx.h"
    #include "MyApp.h"///////////////////////////////////////////////////////////////////////
    // The one and only CWinApp object
    // NOTE: You may remove this object if you alter your project to no
    // longer use MFC in a DLL.CWinApp theApp;///////////////////////////////////////////////////////////////////////
    // command-parsing mapBEGIN_PARSE_MAP(CMyAppExtension, CHttpServer)
    // TODO: insert your ON_PARSE_COMMAND() and 
    // ON_PARSE_COMMAND_PARAMS() here to hook up your commands.
    // For example: ON_PARSE_COMMAND(Default, CMyAppExtension, ITS_EMPTY)
    DEFAULT_PARSE_COMMAND(Default, CMyAppExtension)
    END_PARSE_MAP(CMyAppExtension)
    ///////////////////////////////////////////////////////////////////////
    // The one and only CMyAppExtension objectCMyAppExtension theExtension;
    ///////////////////////////////////////////////////////////////////////
    // CMyAppExtension implementationCMyAppExtension::CMyAppExtension()
    {
    }CMyAppExtension::~CMyAppExtension()
    {
    }BOOL CMyAppExtension::GetExtensionVersion(HSE_VERSION_INFO* pVer)
    {
    // Call default implementation for initialization
    CHttpServer::GetExtensionVersion(pVer); // Load description string
    TCHAR sz[HSE_MAX_EXT_DLL_NAME_LEN+1];
    ISAPIVERIFY(::LoadString(AfxGetResourceHandle(),
    IDS_SERVER, sz, HSE_MAX_EXT_DLL_NAME_LEN));
    _tcscpy(pVer->lpszExtensionDesc, sz);
    return TRUE;
    }///////////////////////////////////////////////////////////////////////
    // CMyAppExtension command handlersUINT MyThreadProc(LPVOID pvParam)
    {
       EXTENSION_CONTROL_BLOCK    *pECB = (EXTENSION_CONTROL_BLOCK *)pvParam;   // Set a header here--let's just add a cookie:
       CString  sHeader;
       
       sHeader = "Content-Type: text/html\r\n";
       sHeader += "Set-Cookie: FOO=Bar; Path=/;\r\n\r\n";   pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER,
          (LPVOID)"200 OK", NULL, (LPDWORD)(LPCTSTR) sHeader);   // Write data to the client...
       CString  sMsg = "<H1> Hello World! </H1>";
       DWORD    dwMsgLen = sMsg.GetLength();   pECB->WriteClient(pECB->ConnID, (LPVOID)(LPCTSTR)sMsg, &dwMsgLen, 0);   pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_DONE_WITH_SESSION, NULL, NULL, 0);   return 0;
    }
    DWORD CMyAppExtension::HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB)
    {
       DWORD    dwResult = CHttpServer::HttpExtensionProc(pECB);   if(dwResult == HSE_STATUS_SUCCESS)
          return HSE_STATUS_PENDING;
       else
          return dwResult;
    }void CMyAppExtension::Default(CHttpServerContext* pCtxt)
    {
       // Turn off automatic header generation...
       pCtxt->m_bSendHeaders = FALSE;   // Spawn thread...
       AfxBeginThread((AFX_THREADPROC)MyThreadProc, (LPVOID)(pCtxt->m_pECB));
    }// Do not edit the following lines, which are needed by ClassWizard.
    #if 0
    BEGIN_MESSAGE_MAP(CMyAppExtension, CHttpServer)
    //{{AFX_MSG_MAP(CMyAppExtension)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    #endif // 0///////////////////////////////////////////////////////////////////////
    // If your extension will not use MFC, you'll need this code to make
    // sure the extension objects can find the resource handle for the
    // module.  If you convert your extension to not be dependent on MFC,
    // remove the comments arounn the following AfxGetResourceHandle()
    // and DllMain() functions, as well as the g_hInstance global./****static HINSTANCE g_hInstance;HINSTANCE AFXISAPI AfxGetResourceHandle()
    {
    return g_hInstance;
    }BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason,
    LPVOID lpReserved)
    {
    if (ulReason == DLL_PROCESS_ATTACH)
    {
    g_hInstance = hInst;
    } return TRUE;
    }****/
      

  5.   

    补充一下用GetServerVariable来获取HTTP HEADER
    CHttpServerContext::GetServerVariable
    BOOL GetServerVariable( LPTSTR lpszVariableName, LPVOID lpvBuffer, LPDWORD lpdwSize );Return ValueNonzero if successful, otherwise 0. If the call fails, the Windows functionGetLastError may be called to determine the cause of the error. Possible error values include:Value Meaning 
    ERROR_INVALID_PARAMETER Bad connection handle. 
    ERROR_INVALID_INDEX Bad or unsupported variable identifier. 
    ERROR_INSUFFICIENT_BUFFER Buffer too small, required size returned in *lpdwSize. 
    ERROR_MORE_DATA Buffer too small, only part of data returned. The total size of the data is not returned. 
    ERROR_NO_DATA The data requested is not available. 
    ParameterslpszVariableNameNull terminated string indicating which variable is being requested. See the Res section for a list of current variables.lpvBufferPointer to buffer to receive the requested information.lpdwSizePointer to DWORD indicating the number of bytes available in the buffer. On successful completion the DWORD contains the number of bytes transferred into the buffer (including the null-terminating byte).ResThis function copies information relating to an HTTP connection, or to the server itself, into a buffer supplied by the caller. Possible values for lpszVariableNames include:Value Meaning 
    AUTH_TYPE Contains the type of authentication used.  For example, if Basic authentication is used, the string will be "Basic".  For Windows NT Challenge-response, it will be "NTLM".  Other authentication schemes will have other strings.  Because new authentication types can be added to Internet Server, it is not possible to list all possible strings. If the string is empty, then no authentication is used. 
    CONTENT_LENGTH The number of bytes which the script can expect to receive from the client. 
    CONTENT_TYPE The content type of the information supplied in the body of a POST request. 
    GATEWAY_INTERFACE The revision of the CGI specification to which this server complies. The current version is CGI/1.1. 
    PATH_INFO Additional path information, as given by the client. This comprises the trailing part of the URL after the extension DLL (script) name but before the query string (if any). 
    PATH_TRANSLATED This is the value of PATH_INFO, but with any virtual path name expanded into a directory specification. 
    QUERY_STRING The information which follows the ? in the URL which referenced this extension DLL. 
    REMOTE_ADDR The IP address of the client. 
    REMOTE_HOST The hostname of the client. 
    REMOTE_USER This contains the username supplied by the client and authenticated by the server.   
    REQUEST_METHOD The HTTP request method. 
    SCRIPT_NAME The name of the extension DLL that is being executed. 
    SERVER_NAME The server's hostname (or IP address) as it should appear in self-referencing URLs. 
    SERVER_PORT The TCP/IP port on which the request was received. 
    SERVER_PROTOCOL The name and version of the information retrieval protocol relating to this request. Normally HTTP/1.0. 
    SERVER_SOFTWARE The name and version of the web server under which the ISA or server extension DLL program is running. 
    ALL_HTTP All HTTP headers that were not already parsed into one of the above variables. These variables are of the form HTTP_<header field name>. 
    HTTP_ACCEPT Special case HTTP header. Values of the Accept: fields are concatenated, separated by ", ". For example, if the following lines are part of the HTTP header:
    accept: */*; q=0.1
    accept: text/html
    accept: image/jpegthen the HTTP_ACCEPT variable will have a value of:*/*; q=0.1, text/html, image/jpeg
     
    CHttpServerContext Overview |  Class Members |  Hierarchy Chart
    --------------------------------------------------------------------------------
    Send feedback to MSDN.Look here for MSDN Online resources.