2012-05-24 50 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> 
相关问题