Question

I have just installed the sample from Urlrewriter.net, but I can't seem to figure out the rule for accomplishing my problem.

Very simple:

If the user is navigated to this page:

http://localhost/UrlRewriteTest/Default.aspx?PageID=33

The Url should look like:

http://localhost/UrlRewriteTest/33

or maybe

http://localhost/UrlRewriteTest/33.aspx

What am I doing wrong? Here is my 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>

That is the first step. More ideally PageID should be passed to a database and return the pagename instead of an ID, and the URL should end up looking like this:

http://localhost/UrlRewriteTest/thename/

Best regards.

Was it helpful?

Solution

You can read Scott Guthrie's article about Url Rewriting @ http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top