• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

onRequest and virtual sites (IIS)

Explorer ,
Feb 19, 2007 Feb 19, 2007

Copy link to clipboard

Copied

So I just converted to application.cfc and added onRequest. On the first attempt it failed because it couldn't load the targetPage. I basically copied the example out of the CF manual.

I tracked it down to my using a virtual directory. I'm using IIS and have several virtual directories with names like "v1.4", "v1.4.2", etc. These represent different versions of software. When I put the application.cfc in the InetPub directory it worked.

The error message I got mentioned something about setting up mappings in the CFADMIN. When I look on the mappings page, I see this comment, "ColdFusion mappings let the cfinclude and cfmodule tags access pages that are outside the Web root. If you specify a path that starts with the mapping's logical path in these tags, ColdFusion looks for the page using the mapping's directory path". That makes sense and it works.

However, it doesn't seem like mappings should be needed, according to the statement on the mapping configuration page. From the perspective of the webapp, the root of the virtual directory is the "Web root" (and was before using application.cfc and onRequest). So did I setup a mapping for nothing? Is there a better way to do this? Why do CFINCLUDES work outside of onRequest but not in onRequest prior to mappings?
TOPICS
Advanced techniques

Views

540

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 19, 2007 Feb 19, 2007

Copy link to clipboard

Copied

Don't *discuss* your code, POST your code...

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2007 Feb 19, 2007

Copy link to clipboard

Copied

Sure, but it is right out of the manual. Here is my onRequest:


<CFFUNCTION NAME="onRequest" RETURNTYPE="void">
<CFARGUMENT NAME="targetPage" TYPE="string" REQUIRED="true"/>
<CFSET DSN="#This.DSN#">
<CFINCLUDE TEMPLATE="#Arguments.targetPage#">
</CFFUNCTION>


The only other thing I did was to configure IIS with virtual directories. The above code works fine when the CFM files are in InetPub (and accesssed at http://www.testserver.com). When I put the files in a virtual directory,c alled "v20" and access as http://www.testserver.com/v20., the following error occurs.


Could not find the included template /v20/index.cfm.
Note: If you wish to use an absolute template path (e.g. TEMPLATE="/mypath/index.cfm") with CFINCLUDE then you must create a mapping for the path using the ColdFusion Administrator. Using relative paths (e.g. TEMPLATE="index.cfm" or TEMPLATE="../index.cfm") does not require the creation of any special mappings. It is therefore recommended that you use relative paths with CFINCLUDE whenever possible.

The error occurred in C:\v20\Application.cfc: line 166

164 : <CFARGUMENT NAME="targetPage" TYPE="string" REQUIRED="true"/>
165 : <CFSET DSN="#This.DSN#">
166 : <CFINCLUDE TEMPLATE="#Arguments.targetPage#">
167 : </CFFUNCTION>
168 :


When I log the value of Arguments.targetPage I get /v20/index.cfm. Why isn't it just /index.cfm? If I create a mapping, it will work, but in my onRequestStart I look for several special pages and have to add "/v20" to the page path. I'd prefer not to do that, since the virtual directory may vary.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 20, 2007 Feb 20, 2007

Copy link to clipboard

Copied

I've just tested what I figured was similar to your situation, and it all
seemed OK to me. Not much help in saying that, other than it's not a
fundamental cock-up in CF

I have this:

C:\webroots\dev (webroot)
C:\temp\Application.cfc (/temp virtual directory off webroot)
C:\temp\test.cfm

If I browse to test.cfm, the onRequest event handler runs (I'm using the
event handler you posted, with a one-line output in it saying "yes, I ran
OK").

Is that pretty much what you've got?

What exact version of CF are you running? I'm running 7,0,2,142559 (J2EE
edition).

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 20, 2007 Feb 20, 2007

Copy link to clipboard

Copied

Yes, sounds like what I have. I just want to stress that I'm creating a virtual directory and not a virtual web site. And I am running version 7,0,2,142559 of CF.

Did you create a mapping in order for this to work?

Also, if you log the targetPath in onRequest (same for onRequestStart), do you see /temp/test.cfm or do you see /test.cfm? I obviously see the first and it doesn't work without a mapping?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 20, 2007 Feb 20, 2007

Copy link to clipboard

Copied

I did a quick experiment that may shed some light on the problem. So far I've been running the app on W2K, which has IIS 5.0 (I think). If I run the same app on W2003 it works fine.

Is anyone having the problem I've observed above on W2K with IIS 5.0? Is this a known problem IIS 5.0?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 20, 2007 Feb 20, 2007

Copy link to clipboard

Copied

LATEST
My tests were on WinXP and whatever-the-hell-half-arsed-version-of-IIS that
comes with.

In answer to the other questions from the preceding post (which could be
moot now), are:
1) a v/dir, not a v/website (don't even know what one of those is!)
2) no CF mapping necessary.

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation