我是URLRewriting的新手并尝试使用web.config中的以下脚本删除.aspx扩展名
<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 :(得分: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>
答案 1 :(得分:0)
以下是一些不错的重写引擎,其中包含操作方法:)
http://www.codeproject.com/Articles/2538/URL-Rewriting-with-ASP-NET
答案 2 :(得分:0)
好像你没有在类URLupwriter的Web项目中添加dll Reference。添加此引用以解决此问题。
答案 3 :(得分:0)