Skip to main content
Participant
February 26, 2010
Question

Assistance getting this.mappings to work

  • February 26, 2010
  • 2 replies
  • 802 views

I have been scouring the net trying to find a solution to my problem but as of yet I've had zero success.

I have the following in my Application.cfc:

<cfset this.mappings['/DefURLVar'] = "c:\inetpub\mywebdir\cfteststuff">

In my testpage.cfm I have:

<a href = "/DefURLVar/testpage.cfm">My Test Page</a>

I don't get an error, but it can't find the page because it is literally looking for a location of /DefURLVar/testpage.cfm.

So I tried the following:

<a href = "/#DefURLVar#/testpage.cfm">My Test Page</a>

Cold Fusion 8 returns DefURLVar is undefined......when I had my mappings in my Application.cfm file they worked just fine.

I understand the advantages of Application.cfc over Application.cfm but I've been spinning on this for several weeks and I'm about ready to revert back to Application.cfm just because I don't have the time to spend trying to make this work.

If someone can point out my obvious error I would be extremely grateful.

I'm currently running the Developer Edition of ColdFusion 8 and IIS v5.1

I have my mappings in the CF Administrator defined.

Thanks in Advance...

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
February 27, 2010

You should create the virtual directory DefURLVar in IIS. As DefURLVar is apparently a constant for your web site, an easier alternative is to do something like this in onApplicationStart:

<cfset application.DefURLVar =  "http://mywebsite/cfteststuff">

The link would then be

<a href = "#application.DefURLVar#/testpage.cfm">My Test Page</a>

Participant
March 1, 2010

Hi BKBK,

I tried your suggestion, unfortunately I now get a message from ColdFusion stating that DefURLVar is undefined in Application.  I tried putting it in onApplicationStart and then I tried putting it outside but I get the same message.

I'll keep messing with it, maybe I'll get lucky. 

Inspiring
March 1, 2010

If you put the web server mapping (virtual directory / alias / whatever) in, you shouldn't need to do anything else.

In the example you originally cited, the only problem was that the web server couldn't find the file.  It's nowt to do with CF: the request isn't even getting to CF because you haven't told the web server that /DefURLVar should point to c:\inetpub\mywebdir\cfteststuff.

--

Adam

Inspiring
February 26, 2010

You're setting a CF mapping and expecting the web server to know about it.  Which is a false expectation.

A CF mapping is for resolving paths in CFML (like for CFC locations, or template locations when you use <cfinclude>), not the HTML that ends up on the browser.  You need a web server mapping for that.

--

Adam