2013-08-12 239 views
0

我正在使用Intelligencia URL重寫,但這些頁面沒有重定向並顯示錯誤404.雖然我在服務器上安裝了重寫模塊。請告訴我我在做什麼錯誤。我的web.config文件如下..URL重寫頁面顯示404錯誤

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

回答

0

首先在你的 asp.net應用程序添加Intelligencia.UrlRewriter dll引用和下面的比在你的網頁設置。配置文件:

<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)將網頁稱爲w2。它會正常工作