2012-05-24 49 views
0

我是新來的URL重寫.aspx擴展,並試圖在我的web.config刪除使用下面的腳本在.aspx擴展刪除從Web應用程序

<configuration> 
    <configSections> 
    <section name="rewriteModule" type="RewriteModule.RewriteModuleSectionHandler, RewriteModule"/> 
    </configSections> 
<connectionStrings> 

<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="Redirect to clean URL" stopProcessing="true"> 
      <match url="^([a-z0-9/]+).aspx$" ignoreCase="true"/> 
      <action type="Redirect" url="{R:1}"/> 
      </rule> 
    </rules> 
    </rewrite> 
</system.webServer> 

不過,我有這個沒有成功。而且,下面的代碼塊給了我一個錯誤。

<httpHandlers> 
     <add verb="*" path="*.aspx" 
      type="URLRewriter.RewriterFactoryHandler, URLRewriter" /> 
</httpHandlers> 

> Could not load file or assembly 'URLRewriter' or one of its 
> dependencies. The system cannot find the file specified. 

是否需要將重寫引擎添加到我的Web應用程序中?

我已經通過this link但我無法得到它。

任何人都可以向我建議一步一步的過程或示例腳本嗎?

+0

如果你使用VS 2010,那麼你可以使用路由代替,http://msdn.microsoft.com/en-us/library/dd329551.aspx –

+0

我使用Visual Studio 2008與IIS 6.0 – bandla

回答

0

好像你還沒有添加Web項目的類URLRewriter的dll參考一些不錯的rewritting引擎。添加此參考來解決此問題。

1

使用下面的規則,每次都像魅力一樣!

<rule name="san aspx"> 
    <!--Removes the .aspx extension for all pages.--> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAll"> 
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="{R:1}.aspx" /> 
</rule> 
相關問題