我刚刚安装了来自Urlrewriter.net的示例,但我似乎找不出解决问题的规则。
非常简单:
如果用户被导航到此页面:
http://localhost/UrlRewriteTest/Default.aspx?PageID=33Url应如下所示:
http://localhost/UrlRewriteTest/33或者也许
http://localhost/UrlRewriteTest/33.aspx我做错了什么?这是我的web.config:
<?xml version="1.0"?>
<configuration>
<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>
<compilation targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<rewriter>
<rewrite url="~/(.+)" to="~/Default.aspx?PageID=$1"/>
</rewriter>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
</configuration>这是第一步。更理想的情况是,应该将PageID传递给数据库,并返回页面名而不是ID,URL最终应该如下所示:
http://localhost/UrlRewriteTest/thename/诚挚的问候。
发布于 2012-08-15 21:34:21
你可以阅读Scott Guthrie关于网址重写@ http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx的文章。
https://stackoverflow.com/questions/11970157
复制相似问题