ColdFusion与IIS网址重写 - 页面从未完成加载 [英] ColdFusion with IIS URL Rewrite - Page never finishes loading

查看:334
本文介绍了ColdFusion与IIS网址重写 - 页面从未完成加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS 7.5上运行CF10,并安装了URL Rewrite模块。
所有重写规则完美工作,ColdFusion返回正确的页面。为了获得在浏览器中显示的页面,我必须手动设置Application.cfc中的content-length值,如下所示:

I am running CF10 on IIS 7.5 with URL Rewrite module installed. All the rewrite rules work perfectly and ColdFusion is returning the correct pages. In order to get the page displayed in the browser I have to manually set the 'content-length' value in Application.cfc like this:

<cfcomponent>

  <cffunction name="onRequestEnd">

  <cfheader name="Content-Length" value="#getPageContext().getCFOutput().getBuffer().size()#" />

  </cffunction>

</cfcomponent>

没有此代码,浏览器不显示页面。但是,即使它现在正在显示页面,它不是正确地做。页面从未完成加载,并且并非所有的HTML内容似乎都在页面上。

Without this code the browser does not display the page. However, even though it is now displaying the page, it is not doing it correctly. The page never finishes loading fully and not all of the HTML content seems to be on the page.

我试图添加一个< cfflush /> 标签,但它没有什么区别。我不明白为什么会发生这种情况,但我知道这是发生在其他人谁使用htaccess: http://forums.devshed.com/coldfusion-development-84/page-not-finishing -loading-coldfusion和-htaccess-bug-575906.html

I have tried to add a <cfflush /> tag after setting the 'content-length' but it makes no difference. I don't understand why this is happening but I know that it has happened to someone else who was using htaccess:http://forums.devshed.com/coldfusion-development-84/page-not-finishing -loading-coldfusion-and-htaccess-bug-575906.html

编辑:示例出站/入站规则定义:

Example Outbound/Inbound Rule Definition:

<!--- Outbound rule --->
<rule name="Rewrite Info Page" preCondition="IsHTML" enabled="false" stopProcessing="false">
<match filterByTags="A" pattern="^(.*)/info\.cfm\?subjectid=([^=&amp;]+)&amp;(?:amp;)?nameid=([^=&amp;]+)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
</conditions>
<action type="Rewrite" value="{R:1}/info/{R:2}/{R:3}" />
</rule>

<preConditions>
<preCondition name="IsHTML">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>


<!--- Inbound rule --->
<rule name="Rewrite Info Page" enabled="true" stopProcessing="false">
<match url="^(.*)/info/([^/]+)/([^/]+)/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}/info.cfm?subjectid={R:2}&amp;nameid={R:3}" appendQueryString="true" />
</rule>



< 标记,类似 http://mysite.com/info.cfm?subjectid=1&nameid=1 ,然后将其重写以显示在我的页面为 http://mysite.com/info/1/1

The Outbound rule is looking at a URL link within an <a> tag that looks like http://mysite.com/info.cfm?subjectid=1&nameid=1 and then rewriting it to appear on my page as http://mysite.com/info/1/1.

Inbound正在寻找类似 http:// mysite / info / 1/1 的链接将其解析/重写为 http://mysite.com/info.cfm?subjectid=1&nameid=1

The Inbound is looking for a link that looks like http://mysite/info/1/1 and resolving/rewriting it to the real URL which is http://mysite.com/info.cfm?subjectid=1&nameid=1

推荐答案

由于IIS URL Rewrite的出站规则给你这么多麻烦,这里是另一个选择。使用ColdFusion重写 onRequestEnd 中的链接。这将允许您在IDE中使用物理路径,使用默认文档,并仍然以所需的格式获取发送到浏览器的出站URL。我更新了我的Gist的详细信息

Since IIS URL Rewrite's outbound rules are giving you so much trouble, here is another option. Use ColdFusion to rewrite the links in onRequestEnd. This will allow you to use physical paths in your IDE, use default documents, and still get the outbound URLs sent to the browser in the desired format. I've updated my Gist with the details.

这里是一个非常基本的方法。关闭web.config中的出站重写规则,并向 Application.cfc 中的 onRequestEnd 函数添加类似的内容。 (我的正则表达式是可怕的,所以这个 reReplace()模式只是部分工作方式你的IIS模式。

Here is a very basic approach. Turn off the outbound rewrite rule in web.config and add something like this to your onRequestEnd function in Application.cfc. (My regex is horrible, so this reReplace() pattern only partially works the way your IIS pattern did.

<cfcomponent>

    <cffunction name="onRequestEnd">
        <!--- Get the generated output --->
        <cfset var output = getPageContext().getCFOutput().getBuffer().toString()>      

        <!--- Apply outbound link rules --->
        <cfset output = reReplace(output, '/info\.cfm\?subjectid=([^=&amp;]+)', '/info/\1', 'all')>

        <!--- Clear the previous output and send the rewritten output in its place --->
        <cfcontent reset="true">
        <cfoutput>#output#</cfoutput>

    </cffunction>

</cfcomponent>

这不会像IIS中的URL Rewrite模块一样好,但它会给你一切你想要实现的您的正则表达式调整)。

This won't perform as well as the URL Rewrite module in IIS, but it will give you everything else you are trying to achieve (once you get your regex tuned up).

这篇关于ColdFusion与IIS网址重写 - 页面从未完成加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆