我正在尝试在我的 ASP.NET 应用程序中实现 Prerender.io。我配置了所有必需的必要步骤,包括
1) <meta name="fragment" content="!">
在指数的头部.html
2) 配置模块
<httpModules>
<add name="Prerender" type="Prerender.io.PrerenderModule, IslamicMatchMakers.Web, Version=1.0.0.0, Culture=neutral" />
</httpModules>
3) 添加了自定义标题
<httpProtocol>
<customHeaders>
<add name="X-Prerender-Token" value="XXXX" />
</customHeaders>
</httpProtocol>
4) 定义的重写规则
<rewrite>
<rules>
<!--# Only proxy the request to Prerender if it's a request for HTML-->
<rule name="Prerender" stopProcessing="true">
<match url="^(?!.*?(.js|.css|.xml|.less|.png|.jpg|.jpeg|.gif|.pdf|.doc|.txt|.ico|.rss|.zip|.mp3|.rar|.exe|.wmv|.doc|.avi|.ppt|.mpg|.mpeg|.tif|.wav|.mov|.psd|.ai|.xls|.mp4|.m4a|.swf|.dat|.dmg|.iso|.flv|.m4v|.torrent))(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_USER_AGENT}" pattern="baiduspider|facebookexternalhit|twitterbot" />
<add input="{QUERY_STRING}" pattern="_escaped_fragment_" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="http://service.prerender.io/http://{HTTP_HOST}/{R:1}" />
</rule>
<rule name="Html5Mode" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{URL}" pattern="/scripts/" negate="true" />
<add input="{URL}" pattern="/content/" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
5) 我在 IIS 上安装了应用程序请求路由模块,在其中启用了代理。这是它的外观:阿瑞
现在,当我向 http://localhost:2525?_escaped_fragment_= 发出请求时,经过所有这些配置后
它只是向我显示一个空白页。我不确定我错过了什么,任何人都可以建议。
如果您在本地主机上运行,您将无法看到任何内容。Prerender.io 服务器只能访问公开可用的网站,因此您可以尝试将代码推送到公共登台服务器...或者下载我们的开源服务器并在本地运行它以首先进行测试。
如果您对启动和运行还有其他疑问,请随时给我发电子邮件! :)
todd@prerender.io