Question

Looking through the logs, we're getting hundreds of the following

"Error","jrpp-185","08/21/12","10:05:43","PATH","www.domain.com 
Agent:Mozilla/4.0 (compatible; Synapse) 
Error: An exception occurred when invoking a event handler method from Application.cfc. 
The method name is: onRequest.

They seem to be mostly search bots. The on place on APplication.cfc that I can see reference to the function is below

<cffunction name="onRequest" returnType="void">
        <cfargument name="targetPage" type="String" required=true/>
        <cfsetting enablecfoutputonly="yes" requesttimeout="20">

        <cfparam name="url.refresh" default="0">
        <cfset request.strMember = Duplicate(session.strMember)/>

        <cfset request.tNow = GetTickCount()>
        <cfif url.refresh EQ 0>
            <cfset request.iCacheHr = 12/>
        <cfelse>
            <cfset request.iCacheHr = 0/>
        </cfif>

        <cflogin>
            <cfif IsDefined("session.strMember.sRoles")>
                <cfloginuser name="#session.strMember.sFirstName##session.strMember.sLastName#"
                    password="12345"
                    roles="#session.strMember.sRoles#"/>
            </cfif>
        </cflogin>

        <cfinclude template="core/incl/SessionLogger.cfm">
        <cfinclude template="core/incl/LinkTranslator.cfm">
        <cfinclude template="core/incl/udf.cfm">

        <cfinclude template="urlcheck.cfm"/>
        <cfinclude template="#Arguments.targetPage#">
    </cffunction>

From that, can anyone please advise on what's wrong and how to fix it? I'm fairly new to CF and this is making me pull out what little hair I have left

Was it helpful?

Solution

1) You use two different coding styles

    <cfparam name="url.refresh" default="0">
    <cfset request.strMember = Duplicate(session.strMember)/>

Invalid/left open XML tags in first line and valid (closed) XML tags in the second line. Try to stick to one (preferably the last one).

2) You are using old way of checking variable being defined

IsDefined("session.strMember.sRoles")

read about newer (and better and faster)

StructKeyExists(session.strMember, "sRoles")

3) Most likely your code is calling

<cfloginuser ... >

at every page request

4) Make sure that paths for all includes are correct and they themselves don't have any errors.

Simplify your method until you stop getting an error and then investigate what exactly is causing it

OTHER TIPS

Are the bots hitting a page that doesn't exist?

Maybe try changing the last line to:

<cfif fileExists(expandPath(Arguments.targetPage))>
    <cfinclude template="#Arguments.targetPage#">
<cfelse>
    <cfabort>
</cfif>

Maybe you could detect if they are a bot and server them something else? depends on how search friendly you want your site to be:

http://www.bennadel.com/blog/1083-ColdFusion-Session-Management-And-Spiders-Bots.htm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top