【问题标题】:URL rewriting pages is showing 404 errorURL 重写页面显示 404 错误
【发布时间】:2013-08-13 15:48:27
【问题描述】:

我正在使用 Intelligencia URL 重写,但这些页面没有重定向并显示错误 404。虽然我在服务器上安装了重写模块。请告诉我我在做什么错误。我的 web.config 文件在下面..

<?xml version="1.0"?>

<configuration>
   <configSections>
   <section name="rewriter" requirePermission="false"   type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
  </configSections>  
<appSettings/>
<connectionStrings>
    <add name="connStr" connectionString="Data Source=INV-DEV-SQL2K5;Initial Catalog=WidenerPortal;Persist Security Info=True;User ID=widener;Password=widener123a" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<httpModules>
  <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
</httpModules>       
    <!-- 
        Set compilation debug="true" to insert debugging 
        symbols into the compiled page. Because this 
        affects performance, set this value to true only 
        during development.
    -->
    <compilation debug="true"/>
    <!--
        The <authentication> section enables configuration 
        of the security authentication mode used by 
        ASP.NET to identify an incoming user. 
    -->
    <authentication mode="Windows"/>
    <!--
        The <customErrors> section enables configuration 
        of what to do if/when an unhandled error occurs 
        during the execution of a request. Specifically, 
        it enables developers to configure html error pages 
        to be displayed in place of a error stack trace.

    <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
        <error statusCode="403" redirect="NoAccess.htm" />
        <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>
    -->
</system.web>
  <rewriter>
     <rewrite url="~/Article/(.+)-(.+).aspx" to="~/DynamicPage.aspx?MyTitleId=$2"/>
 </rewriter>  
</configuration>

【问题讨论】:

    标签: asp.net c#-4.0 url-rewriting


    【解决方案1】:

    首先将 Intelligencia.UrlRewriter dll 引用添加到您的 asp.net 应用程序和您的 web.config 文件中的以下设置:

    <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="w1" to="WebForm1.aspx" />
        <rewrite url="w2" to="WebForm2.aspx" />
    </rewriter>
    
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules runAllManagedModulesForAllRequests="true">
          <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
        </modules>
    </system.webServer>
    

    尝试使用 webform2.aspx 等新 URL 调用您的页面作为 w2。它会正常工作

    【讨论】:

    • 非常感谢您在这方面帮助我。它对我有用。很大的努力
    【解决方案2】:

    使用这个。 Mode=RemoteOnly 仅在您从其他主机访问时重定向

    <customErrors mode="On" defaultRedirect="GenericErrorPage.htm">
    

    或访问http://urlrewriter.net/index.php/support/reference/error-handler/error-page

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-11
      • 2014-06-25
      • 1970-01-01
      • 1970-01-01
      • 2013-06-06
      • 1970-01-01
      • 2013-04-09
      • 2012-11-22
      相关资源
      最近更新 更多