Or, if you're too lazy to read the documentation (as if!), I'll quote the relevant paragraph here for you:
- Implement this method only if the following are true:
- The directory, and any subdirectories affected by this Application.cfc contain CFM files and do not contain any CFC files that are intended to be accessed as web services, using Flash Remoting, or using an event gateway.
- You want to intercept the request and process it in a special way.
Think about how onRequest() works - it <cfinclude>s the target page in order to complete the request. How could it do that for a CFC request that comes in as a Web Service, Flash Remoting or Event Gateway request? How would it know about arguments etc? Answer: it can't.
So, if you use Application.cfc and need onRequest() for manipulating a CFM page request and you want to offer CFCs as Web Services, Flash Remoting or Event Gateways then you need to put them in a separate directory and have another Application.cfc in that directory that does not have an onRequest() method.
If you happen to get this, I would appreciate and reply.
I have a root Application.cfc (x:\projectname\) and have successfully extended that into another folder (x:\projectname\ws\) and use cfNTauthenticate to control access there. I am adding a webservice to this application and would like to extend the root Appliation.cfc so I can use application variables. When extending an Application.cfc file, I understand that if I omit a method, it simply inherits the root. If I include a method, you basically start it from scratch - unless I have that wrong to begin with. But if I include the OnRequstMethod() then the web service (as stated above) is not able to execute. I have this working with Application.cfm but wonder two things. a.) Can I define the onRequest method in my (x:\projectname\ws\) Application.cfc but void it out some how, so the web service will not inherit the root CFC and then work? b.) Or, can I simply extend the root CFC application scope variables in the (x:\projectname\ws\) Application.cfm?
Thanks for any help you might have here.
What you need to do in your sub-Application.cfc is inside onRequestStart(), use structDelete() on THIS and VARIABLES scope to remove onRequest(). Ray Camden blogged this some time ago (he credits the tip to me - I was just slow to blog it).
Putting <cfscript> structDelete(variables,"onRequest"); structDelete(this,"onRequest"); </cfscript>
in my extended Application.cfc. (sorry)
It works for me, but maybe it has some evil side effects that I will learn later.
Application.cfc:
<!--- ensure CFC / Web Service / Flex Remoting calls are not intercepted --->
<cfif right(arguments.targetPage,4) is ".cfc">
<cfset doCompile = false />
<cfset structDelete(variables,"onRequest") />
<cfset structDelete(this,"onRequest") />
</cfif>


