Coldfusion cfheader代码500而不是410消失
我想显示状态代码410,但它显示的是状态代码500。有人能解释为什么吗 我正在使用IIS7和ColdFusion 9。这是我的代码:Coldfusion cfheader代码500而不是410消失,coldfusion,coldfusion-9,Coldfusion,Coldfusion 9,我想显示状态代码410,但它显示的是状态代码500。有人能解释为什么吗 我正在使用IIS7和ColdFusion 9。这是我的代码: <cfheader statuscode="410" statustext="Gone" /> <cfinclude template="../cgi-bin/file_not_found.cfm"> <cfabort> 这是my application.cfc文件: <cfcomponent output="No"&g
<cfheader statuscode="410" statustext="Gone" />
<cfinclude template="../cgi-bin/file_not_found.cfm">
<cfabort>
这是my application.cfc文件:
<cfcomponent output="No">
<cfinclude template="f/login.cfm" >
<!--- <cfinclude template="f/security.cfm"> --->
<cfset this.clientmanagement=true>
<cfset this.sessionmanagement="yes">
<cfset this.name="UL">
<cfset this.clientstorage="cookie">
<cfset this.setclientcookies="true">
<cffunction name="OnSessionStart">
<!--- 1111 --->
<!--- set defualt buyer session anyway! --->
<cfset SetDefaultBuyer()>
<cfset SetDefaultSeller()>
<!--- define session and client mylist --->
<cfset session.mylist="">
<!--- <cfif isdefined("client.mylist")><cfset session.mylist=client.mylist><cfelse><cfset session.mylist=""><cfset client.mylist=""></cfif> --->
<!--- trying to login as user --->
<cf_LoginCookies>
<cfif FindNoCase('pa_',CGI.PATH_TRANSLATED) AND ( NOT ISDefined("session.user.status")) >
<cflocation addtoken="No" url="#Application.URL#/p_login/login_form.cfm">
</cfif>
</cffunction>
<cffunction name="OnApplicationStart">
<cfinclude template="including/global_variables.cfm">
</cffunction>
<cffunction name="onRequestStart" returnType="boolean">
<!---
<cfif CGI.REMOTE_ADDR IS "81.218.200.52">
<cfelse>
<cfoutput><br> <br> <br>
<h2 align="center">Sorry,<br>
We are in process of maintenance.<br>
Please try at 10:00 AM<br>
Now is #Timeformat(now())#</h2></cfoutput>
<cfabort>
</cfif>
--->
<!--- 2222 --->
<!--- Neged atacks --->
<cfparam name="CGI.QUERY_STRING" default="222">
<cfif FindNoCase('Declare',CGI.QUERY_STRING)>
<cfabort>
</cfif>
<cfif Len(CGI.QUERY_STRING) GT 400>
<cfabort>
</cfif>
<!--- im menase lirot MyUL bli lihiot LogIn --->
<cfif FindNoCase('pa_',CGI.PATH_TRANSLATED) AND ( NOT ISDefined("session.user.status")) AND ( NOT ISDefined('form.type') )>
<cflocation addtoken="No" url="#Application.URL#/p_login/login_form.cfm">
</cfif>
<cfreturn True>
</cffunction>
<cfif CGI.HTTP_HOST IS not "192.168.1.223">
<cffunction name="onError">
<cfargument name="Except" required=true/>
<!--- Log all errors in an application-specific log file. --->
<!--- define message --->
<cfif isdefined('except.cause.cause.message')>
<cfset message=except.cause.cause.message>
<cfelseif isdefined('except.cause.message')>
<cfset message=except.cause.message>
<cfelse>
<cfset message=''>
</cfif>
<!--- define template --->
<cfif isdefined('except.cause.tagcontext')>
<cfset template=except.cause.tagcontext[1].template>
<cfset line=except.cause.tagcontext[1].line>
<cfelse>
<Cfset template=''>
<Cfset line=''>
</cfif>
<!--- define second template --->
<cfif arraylen(except.cause.tagcontext) gt 1>
<cfset template= template & ',' & except.cause.tagcontext[2].template>
<cfset line=line & ',' & except.cause.tagcontext[2].line>
<cfelse>
</cfif>
<!--- define third template --->
<cfif arraylen(except.cause.tagcontext) gt 2>
<cfset template= template & ',' & except.cause.tagcontext[3].template>
<cfset line=line & ',' & except.cause.tagcontext[3].line>
<cfelse>
</cfif>
<cfset text="Message: #message# , template:#template# , line:#line#">
<!--- define sql --->
<cfif isdefined('except.cause.sql')>
<cfset text=text & ' , sql:' & except.cause.sql>
</cfif>
<cflog file="MyAppLog" type="error" text="#text# ,client_ip: #cgi.REMOTE_ADDR# , url:#cgi.HTTP_URL#,ref:#cgi.HTTP_REFERER#">
<cfinclude template="/including/error.cfm">
<!--- <cflocation addtoken="false" url="#application.url#/including/error.cfm?message=#message#&template =#template#&line=#line#">
---> </cffunction></cfif>
<cffunction name="onRequest" returnType="boolean">
<cfargument name="targetPage" type="String" required=true/>
<cfinclude template="f/security.cfm">
<cfinclude template="#Arguments.targetPage#">
<cfreturn True>
</cffunction>
<!---
<cferror type = "request"
template = "../including/error.cfm"
mailto = "dtpozner@gmail.com"> --->
<cffunction name="onRequestEnd" returnType="boolean">
<cfreturn True>
</cffunction>
</cfcomponent>
这是我的web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="C page detailed">
<match url="^(.*)/(.*)-(.*)/cc_(.*)_s(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/c_page/index.cfm?id={R:4}&cat_id={R:5}&manuf={R:2}& model={R:3}" />
</rule>
<rule name="C page less detailed">
<match url="/cc_(.*)_s(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/c_page/index.cfm?id={R:1}&cat_id={R:2}" />
</rule>
<rule name="C Pages">
<match url="/cc_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/c_page/index.cfm?id={R:1}" />
</rule>
<rule name="B Page Pnumbers" stopProcessing="true">
<match url="/bb_(.*)_pn(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/c_index.cfm?cat_id={R:1}&pnumber={R:2}" />
</rule>
<rule name="B Pages">
<match url="/bb_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/c_index.cfm?cat_id={R:1}" />
</rule>
<rule name="TM Guide B Pages">
<match url="/tmm_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="tm_guide/cat_view.cfm?cat_id={R:1}" />
</rule>
<rule name="TMGuide C Page">
<match url="/tmc_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="tm_guide/model.cfm?model_id={R:1}" />
</rule>
<rule name="T&M-Buying-Guide" stopProcessing="true">
<match url="^T&M-Buying-Guide" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="tm_guide/index.cfm" />
</rule>
<rule name="Home Page">
<match url="^$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/homepage/index.cfm" />
</rule>
<rule name="A Page Pnumbers">
<match url="/aa_(.*)_pn(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/m_index.cfm?main_id={R:1}&pnumber={R:2}" />
</rule>
<rule name="A Pages">
<match url="/aa_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/m_index.cfm?main_id={R:1}" />
</rule>
<rule name="GogglePageModeID">
<match url="/gm_model_id(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}" />
</rule>
<rule name="GoogleModelManufCat">
<match url="/gmm_model(.*)_manuf(.*)_cat(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}&manuf={R:2}&cat={R: 3}" />
</rule>
<rule name="old b_pages" stopProcessing="true">
<match url="^b(\d+?)p(\d+?)pr(\d+?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="category/c_index.cfm?cat_id={R:1}&pnumber={R:2}&old=1" />
</rule>
<rule name="old c_pages" stopProcessing="true">
<match url="^c(\d+?)s(\d+?)-(.*?)_(.*?)\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="/c_page/index.cfm?id={R:1}&cat_id={R:2}&manuf={R:3}& model={R:4}&old=1" />
</rule>
<rule name="old c page no model" stopProcessing="true">
<match url="^c(\d+?)s(\d+?)-(.*?).htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="/c_page/index.cfm?id={R:1}&cat_id={R:2}&manuf={R:3}& old=1" />
</rule>
<rule name="old b_tb_pages" stopProcessing="true">
<match url="^b-(.*?)pn(\d+?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="tm_guide/cat_view.cfm?cat_id={R:1}&old=1" />
</rule>
<rule name="old c_tb_pages" stopProcessing="true">
<match url="^c-(.*?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="tm_guide/model.cfm?model_id={R:1}&old=1" />
</rule>
<rule name="old b_model_page" stopProcessing="true">
<match url="^b_model_mf(.*?)_mo(.*?)_pn(.*?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="CustomResponse" statusCode="410" statusReason="Removed" statusDescription="Removed" />
</rule>
<rule name="old b_manuf_sec_all" stopProcessing="true">
<match url="^cgi-bin/a_dinamic/b_manuf_sec_all.cfm(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="http:www.used-line.com" appendQueryString="false" />
</rule>
<rule name="result.cfm" stopProcessing="true">
<match url="^cgi-bin/a_dinamic/result.cfm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="list_of_categories/categories.cfm" />
</rule>
<rule name="old b model">
<match url="^.*_.*_m(.*?).htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}" />
</rule>
<rule name="old b model mfr cid">
<match url="^.*_.*_2m(.*?)_2mnf(.*?)_2cid(.*?).htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}&manuf={R:2}&cat={R: 3}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
正如Seybsen所说,出现错误时会返回500状态码。错误可能发生在您点击带有cfheader的页面之前,因此在您可以设置状态代码之前或在文件_not_found.cfm中中止处理,其中错误状态代码将覆盖您设置的状态代码。主要问题是这里的500。您可以在IIS中启用失败的请求跟踪,因为错误500是由Web服务器引发的。同时,分析异常/应用程序日志以获取相关信息。我还希望得到一个关于这个问题的更有用的答案,该答案在Windows 2008 R2上的CF10中仍然可以重现 我用一个空白的Application.cfc创建了一个新目录,其中有一个Index.cfm页面,其中包含以下内容:传入一个状态码,该状态码不是200,而是返回一个500错误码
<cfparam name="StatusCode" default="200">
<cfparam name="StatusText" default="OK">
<cfif StatusCode EQ "200">
<cfset variables.message = "Success">
<cfelse>
<cfset variables.message = StatusText>
</cfif>
<cfheader statuscode="#StatusCode#" statustext="#StatusText#">
<cfoutput>Message:#variables.message#</cfoutput>
<cfabort>
coldfusion服务的页面产生了状态代码500的错误,因此您的代码中很可能存在错误。这是如何回答问题的?