0

我正在使用URL Rewriter.NET(与 URL Rewriting.NET 相比,我非常喜欢它 - 看起来更通用,不要误会我的意思,我喜欢 URL Rewriting.NET,但它似乎没有鉴于我对该工具的了解,以满足需求)。我正在尝试使用default-documents节点重新定义站点的默认文档。我尝试将其添加到重写器节点,但出现 web.config 错误

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: The element 'default-documents' is not allowed.

Source Error: 


Line 187:
Line 188:   <rewriter>
Line 189:       <default-documents>
Line 190:           <document>default.aspx</document>
Line 191:           <document>index.aspx</document>

过去有没有人使用过这个工具,有没有人知道把这个节点放在哪里(或正确使用)?

编辑:

我尝试了下面的建议,但它似乎并不完全正确。这是我的额外配置文件中的内容(这是配置文件中的唯一内容)

<rewriter>
        <rewrite url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js)(\?.+)?)$" to="$1" processing="stop" />
        <default-documents>
            <document>default.aspx</document>
            <document>index.aspx</document>
        </default-documents>
</rewriter>
4

3 回答 3

1

我以前使用过 urlrewriter,并且在实际设置默认文档时也遇到了一些问题。然而,最终我们通过将 urlrewriter 配置移动到与 web.config 不同的配置文件来让它(和其他小麻烦)工作。

<rewriter configSource="urlrewriter.config"/>

请记住,您还必须禁用 IIS 中的默认文档才能使 urlrewriter 正常工作。这也引起了一系列烦人的问题。

编辑:不要忘记将此行添加到 web.config 中的配置部分

<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>

希望这可以帮助。

于 2009-03-26T14:50:04.517 回答
1

这个片段对我有用:

    <configSections>
        <section name="rewriter" 
                 requirePermission="false" 
                 type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" 
        />
    </configSections>

    <rewriter>
        <default-documents>
            <document>index.aspx</document>
        </default-documents>
    </rewriter>

编辑:确保在添加通配符应用程序映射的位置,还取消选中“验证该文件是否存在”。如果你不这样做,default-documents 不会做任何事情。

另一个编辑:找到说明“验证该文件是否存在”复选框的安装步骤。请参阅此处的第 8 步:

于 2009-03-26T15:00:24.177 回答
0

我相信这个问题的解决方案是我在网站上使用的 .NET 版本。我使用的是 2.0 运行时,而 dll 是为 1.1 运行时构建的。我在网站上看到 2.0 运行时仍在 RC 中(自 2007 年中期以来),因此我不会在这个生产网站上使用它。相反,我想出了如何使用 URL Rewriting.NET 来实现相同的目标。

我添加了以下规则:

<add name="Redirect54" virtualUrl="~/content/myvirtualpage.aspx"
    rewriteUrlParameter="ExcludeFromClientQueryString"
    destinationUrl="~/content/mydestinationpage.aspx?id=9"
    redirect="None"   
    ignoreCase="true"  />

这会导致 myvirtualpage.aspx 上的 HTTP 200 响应,而不是重写。最终目标是让 mydestinationpage.aspx?id=9 有一个 301 到 myvirtualpage.aspx,然后它将为 myvirtualpage.aspx 提供 200 HTTP 响应。不过这有点不对劲。

于 2009-03-26T16:28:28.213 回答