Код 500 заголовка вместо 410 пропал - PullRequest
1 голос
/ 25 марта 2012

Я хочу показать код состояния 410, но вместо этого он показывает код состояния 500. Кто-нибудь может объяснить, почему?

Я использую IIS7 и ColdFusion 9. Это мой код:

<cfheader statuscode="410" statustext="Gone" />
<cfinclude template="../cgi-bin/file_not_found.cfm">
<cfabort>

Это мой файл 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}&amp;cat_id={R:5}&amp;manuf={R:2}&amp; 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}&amp;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}&amp;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&amp;M-Buying-Guide" stopProcessing="true">

                    <match url="^T&amp;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}&amp;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}&amp;manuf={R:2}&amp;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}&amp;pnumber={R:2}&amp;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}&amp;cat_id={R:2}&amp;manuf={R:3}&amp; model={R:4}&amp;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}&amp;cat_id={R:2}&amp;manuf={R:3}&amp; 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}&amp;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}&amp;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}&amp;manuf={R:2}&amp;cat={R: 3}" />

                </rule>

            </rules>

        </rewrite>



    </system.webServer>

</configuration>

Ответы [ 3 ]

2 голосов
/ 26 марта 2012

Как сказал Сейбсен, код 500 возвращается при возникновении ошибки. Ошибка может произойти до того, как вы попадете на страницу с помощью cfheader (поэтому обработка прерывается, прежде чем вы сможете установить код состояния) или в файле file_not_found.cfm, где код ошибки переопределяет заданный вами код состояния.

0 голосов
/ 15 октября 2014

Мне также хотелось бы получить более полезный ответ по этому вопросу, который все еще можно воспроизвести в CF10 в Windows 2008 R2.

Я создал новый каталог с пустым 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>
0 голосов
/ 31 января 2014

Здесь основной проблемой является 500. Вы можете включить «Отслеживание невыполненных запросов в IIS, так как веб-сервер выдает ошибку 500. В то же время проанализируйте журнал исключений / приложений для получения соответствующей информации.

...