Url重写不在服务器上运行

时间:2010-11-12 05:27:52

标签: c# asp.net url-rewriting

我在UrlRewriting.net上所做的工作在我本地测试时效果很好, 它不在网上工作为什么?有配置吗? 我刚刚做了ScottGu所说的话: link text

感谢inadvance     

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

  <system.web>

    <httpModules>
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
    </httpModules>

  </system.web>

  <rewriter>
    <rewrite url="~/products/books.html" to="~/products.aspx" />
  </rewriter>  

</configuration>  

1 个答案:

答案 0 :(得分:2)

以下是您需要的重要部分:

<?xml version="1.0"?>
<configuration>

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

        </configSections>

        <system.web>
            <httpModules>
                <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
            </httpModules>
        </system.web>

        <system.webServer>
            <validation validateIntegratedModeConfiguration="false"/>
            <modules runAllManagedModulesForAllRequests="true">
                <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
            </modules>

                <!-- THE FOLLOWING LINE MUST BE PRESENT FOR AJAX & VALIDATION TO WORK WITH URLREWRITER.NET -->
                <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

            </handlers>
        </system.webServer>

        <!-- URL REWRITER -->
        <rewriter>
            <rewrite url="^~/About$" to="~/About.aspx" />
        </rewriter>
    </configuration>

我的建议是,如果您能够使用.Net 4,请使用URL路由 - 更好。