Access asp.net request headers. How to?

Topics: Developer Forum
Nov 11, 2013 at 6:52 AM
I' am working in version 5.53 of AVFP.
I' am trying to detect if a request is AJAX-request. This is needed for me when I turn on debugger (&dubug=on). But if the request is ajax-request, the debugging info-table is included in response-json (see main.prg). So, I have to have finction for determining if a request is ajax, and do not include debuggin info. So, by my mind, I need analyse request.Headers("x-requested-with") variable:
bIncludeDebugInfo=.T.
 s=oRequest.oRequest.Headers("x-requested-with")
IF s=="XMLHttpRequest"
    bIncludeDebugInfo=.F.
ENDIF
.....
But there is error: Headers does not evaluated to object?
Why?
I'm trying include a list of oResponse.oResponse.Headers in aspvars.prg, but the error is the same.
Please, help me.
Is it possible to access Request.Headers?
In now days I analalyse the end of action for string "_ajax", but it is the bad solution.
Sorry for my English. I'm from Russia.
Nov 11, 2013 at 9:50 AM
Edited Nov 11, 2013 at 9:51 AM
I'm solved this problem. I decide that oRequest is not a asp.net object, but a classic-asp object.
And now I write that code for determining AJAX-call:
* Not worked because oRequest has no object Headers ???
* Solved with ServerVariables("HTTP_X_REQUESTED_WITH") see below
FUNCTION IsAjax
    LOCAL bRet,xReqW
    xReqW=NVL(oRequest.oRequest.ServerVariables("HTTP_X_REQUESTED_WITH").ITEM(),"")
        bRet=IIF(xReqW=="XMLHttpRequest",.T.,.F.)
RETURN bRet
Thanks for you for the GREAT AVFP product!
Coordinator
Nov 11, 2013 at 10:39 AM
mike65,
Yes, AVFP uses the classic ASP objects.

Titu1 is using the debugger in AVFP 6.03 if you're interested in using it in the latest version:

https://activevfp.codeplex.com/discussions/464823