【问题标题】:Url Rewriting not working on the server网址重写在服务器上不起作用
【发布时间】:2010-11-12 15:18:09
【问题描述】:

我对 UrlRewriting.net 所做的工作在我本地测试时运行良好, 它在互联网上不起作用,为什么?有什么配置吗? 我只是做了 ScottGu 所说的: link text

谢谢提前

  <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>  

【问题讨论】:

  • 提供更多信息,我们猜不出问题出在哪里……
  • 您看到的行为是什么?您是两次都在 IIS 上运行,还是在本地使用开发服务器?
  • 您遇到的错误/异常是什么?互联网版本在什么操作系统上运行?
  • 没有错误(只是找不到错误 404 页面)它只是不工作我在我的计算机上的 IIS7 上测试它工作但在互联网上不是这样
  • @Kiarash:确保 AppPool 在集成模式下运行。

标签: c# asp.net url-rewriting


【解决方案1】:

这是您需要的重要部分:

<?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 Routing - 它会更好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-31
    • 1970-01-01
    • 2015-04-01
    • 2018-04-13
    • 1970-01-01
    • 2017-07-10
    相关资源
    最近更新 更多