Hey Daniel,
Many thanks for this tremendous post.
This is exactly what i needed to get me started in troubleshooting
this issue.
I will have a look at integrating into my system and see how it works.
I do have file upload forms which means i would also be looking at a
solution/assistance for this problem as well.
Thanks so much mates, this is great.
Cheers,
On Jul 13, 6:43 pm, "Daniel Crowther" <[EMAIL PROTECTED]>
wrote:
> Hi Rony
>
> We currently use the 404 Error redirect system from our systems. The code
> below working for URL and FORM Data, except when file upload is required (eg
> multipart/form-data forms, we have some code to do these, but it is not as
> straight forward as the normal form post data). I have created an exact of
> our system with just the IIS 404 system, This is how we set the system up.
>
> Using Coldfusion 7 with IIS 6 on Windows 2003 server.
>
> IIS Setup.
>
> Home Directory Tab
>
> - Click "Configuration" button, in the Wildcard application maps
> select the jrun_iis6_wildcard.dll and click edit. Make sure that "Verify
> that file exists is ticked (if it is unticked it will not work)
>
> Custom Error Tab
>
> - Set 404 "Message Type:" to URL and "URL" to /index.cfm (or whatever
> page you wish to do the processing after the URL/Form variables have been
> reprocessed.)
>
> - I cannot remember exactly, but the 405 might also need to be set to
> that URL on IIS5.
>
> ################################ Start Code
> ####################################
>
> Application.cfc
>
> <cfcomponent>
>
> <cffunction name="onRequestStart">
>
> <h3>Data Dump before URL 404</h3>
>
> <cfinclude template="DataDump.cfm">
>
> <cfscript>
>
> if (left(cgi.query_string,4) eq '404;') {
>
> // Step 1. Capture Query String into URL404 variable
>
> URL404.Original = cgi.query_string;
>
> // Step 2. Clean 404 Error
>
> URL404.Complete =
> replace(URL404.Original,"404;http://#cgi.server_name#:#cgi.server_port#/",""
> ,"ALL");
>
> // Step 3. Capture for Actual Query Param
>
> if (FindNoCase("?",URL404.Complete)) {
>
> URL404.ActualQueryString =
> ListGetAt(URL404.Complete, 2, "?");
>
> URL404.Complete =
> ListDeleteAt(URL404.Complete, 2, "?");
>
> }
>
> if (FindNoCase("&",URL404.Complete)) {
>
> URL404.ActualQueryString =
> ListGetAt(URL404.Complete, 2, "&");
>
> URL404.Complete =
> ListDeleteAt(URL404.Complete, 2, "&");
>
> }
>
> if (FindNoCase(";",URL404.Complete)) {
>
> URL404.sessionstring =
> ListGetAt(URL404.Complete, 2, ";");
>
> URL404.jsessionid =
> ListGetAt(URL404.sessionstring, 2, "=");
>
> URL404.Complete =
> ListDeleteAt(URL404.Complete, 2, ";");
>
> }
>
> // Step 4. Capture Filename from Query String
>
> URL404.Include = ListGetAt(URL404.Complete,
> listlen(URL404.Complete,"/") , "/");
>
> // Step 5. Check that Filename exists, must contain
> a dot
>
> if (findnocase(".", URL404.Include)) {
>
> URL404.VirtualQuerystring =
> ListDeleteAt(URL404.Complete, listlen(URL404.Complete,"/") , "/");
>
> } else {
>
> URL404.Include = "index.htm";
>
> URL404.VirtualQuerystring = URL404.Complete;
>
> }
>
> if(find(".",URL404.Include)) {
>
> URL404.Extension =
> listLast(URL404.Include,".");
>
> } else {
>
> URL404.Extension = "";
>
> }
>
> url["Extension"] = URL404.Extension;
>
> // Step 6. Split Virtual Query String Back into URL
> Variables.
>
> ActionList = "";
>
> for(QCounter=1; QCounter LTE
> ListLen(URL404.VirtualQuerystring,"/"); QCounter=QCounter+1) {
>
> QItem =
> ListGetAt(URL404.VirtualQuerystring,QCounter,"/");
>
> if (FindNoCase(":",QItem)) {
>
> //For
> Examplehttp://www.somedomain.com/var_a:1/var_b:2/index.htmwill result in
> url.var_a
> = 1 and url.var_b=2
>
> url[ListGetAt(QItem, 1, ":")] =
> "#ListGetAt(QItem, 2, ":")#";
>
> } else {
>
> // If variable is not a list pair
> seperated by colons, then add to comma seperated list.
>
> ActionList =
> listappend(ActionList,QItem);
>
> }
>
> }
>
> url["UrlActionList"] = ActionList;
>
> // Step 7. Split Actual Query String Back into URL
> Variables.
>
> if (isDefined("URL404.ActualQuerystring")) {
>
> variables[ListGetAt(ListGetAt(URL404.ActualQuerystring, 1 , "&"), 1, "=")]
> = "#ListGetAt(ListGetAt(URL404.ActualQuerystring, 1 , "&"), 2, "=")#";
>
> url[ListGetAt(ListGetAt(URL404.ActualQuerystring, 1 , "&"), 1, "=")] =
> "#ListGetAt(ListGetAt(URL404.ActualQuerystring, 1 , "&"), 2, "=")#";
>
> } else {
>
> // No additional query parameters exist.
>
> }
>
> //Step 8. Capture Form Variables
>
> URL404.VirtualPrequestData = gethttprequestdata();
>
> if
> (StructKeyExists(URL404.VirtualPrequestData.headers,"Content-Type") AND
> (FindNoCase("application/x-www-form-urlencoded",URL404.VirtualPrequestData.h
> eaders["Content-Type"]))) {
>
> //Normal Form Post.
>
> URL404.VirtualFormData =
> URL404.VirtualPrequestData.content;
>
> for(FCounter=1; FCounter LTE
> ListLen(URL404.VirtualFormData,"&"); FCounter=FCounter+1) {
>
> FItem =
> ListGetAt(URL404.VirtualFormData,FCounter,"&");
>
> if (FindNoCase("=",FItem)) {
>
> form[ListGetAt(FItem, 1, "=")] =
> "#URLDecode(ListGetAt(FItem, 2, "="))#";
>
> }
>
> }
>
> } else if
> (StructKeyExists(URL404.VirtualPrequestData.headers,"Content-Type") AND
> (FindNoCase("multipart/form-data",URL404.VirtualPrequestData.headers["Conten
> t-Type"]))) {
>
> //Multipart Encoded Form Post (EG When
> uploading a File)
>
> URL404.VirtualFormData =
> URL404.VirtualPrequestData.content;
>
> URL404.VirtualFormDataBoundary =
> listgetat(URL404.VirtualPrequestData.headers["Content-Type"],2,"=");
>
> //Decode Binary to String
>
> // INSERT CODE TO DECODE BINARY DATA HERE
>
> }
>
> } else {
>
> URL404 = StructNew();
>
> }
>
> </cfscript>
>
> <!--- The following code is to force a 404, when the extension
> is not an allow extension. Required for missing Images and other file types.
> --->
>
> <cfif (len(URL404.Extension) and NOT
> ListFindNoCase("htm,html,cfm,cfml",URL404.Extension))>
>
> <!--- Send 404 Header Response --->
>
> <cfheader statuscode="404" statustext="Not Found">
>
> <!--- <cfinclude template="Error404.cfm"> --->
>
> <cfelse>
>
> <!--- Send 200 Header Response, Required when page was
> generated from Custom URL 404 --->
>
> <cfheader statuscode="200" statustext="OK">
>
> </cfif>
>
> <hr>
>
> <h3>Data Dump after URL 404</h3>
>
> <cfinclude template="DataDump.cfm">
>
> <br>
>
> </cffunction>
>
> </cfcomponent>
>
> Index.cfm - This page will be executed after the application.cfc has been
> processed.
>
> <cfheader statuscode="200" statustext="OK">
>
> <h3>This is the index.cfm page.</h3>
>
> <cfdump var="#url#">
>
> DataDump.cfm - This file is just to show the data before and after the URL
> 404 data has been processed
>
> <cfdump var="#cgi.query_string#" label="Query String Data"><br>
>
> <br>
>
> <cfdump var="#url#" label="URL Data">
>
> <br>
>
> <cfdump var="#form#" label="Form Data">
>
> <br>
>
> <cfdump var="#variables#" label="Variables Data">
>
> Formtest.htm
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>
> <html>
>
> <head>
>
> <title>IIS 404 test</title>
>
> </head>
>
> <body>
>
> <h3>Normal Form - Get Method</h3>
>
> <form action="/form/test1/index.htm" method="get" name="Form1" id="Form1">
>
> <input type="hidden" name="hiddenfield" value="hiddenvalue">
>
> <input type="input" name="inputfield" value="inputvalue"><br>
>
> <input type="submit" value="submit"><br>
>
> </form>
>
> <br>
>
> <h3>Normal Form - Post Method</h3>
>
> <form action="/form/test2/index.htm" method="post" name="Form1" id="Form1">
>
> <input type="hidden" name="hiddenfield" value="hiddenvalue">
>
> <input type="input" name="inputfield" value="inputvalue"><br>
>
> <input type="submit" value="submit"><br>
>
> </form>
>
> <br>
>
> <h3>multipart/form-data Form - Post Method</h3>
>
> <form action="/form/test3/index.htm" method="post"
> enctype="multipart/form-data" name="Form1" id="Form1">
>
> <input type="hidden" name="hiddenfield" value="hiddenvalue">
>
> <input type="input" name="inputfield" value="inputvalue"><br>
>
> <input type="file" name="File1"><br>
>
> <input type="submit" value="submit"><br>
>
> </form>
>
> </body>
>
> </html>
>
> ################################ End Code
> ####################################
>
> I have included the DataDump.cfm file, to show that data is seen in each
> scope before and after the URL 404 is processed....
>
> read more >>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---