2

Urlrewriter.netからサンプルをインストールしたばかりですが、問題を解決するためのルールがわからないようです。

非常に簡単:

ユーザーがこのページに移動した場合:

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

URLは次のようになります。

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/

よろしくお願いします。

4

1 に答える 1

1

UrlRewritingに関するScottGuthrieの記事は、http: //weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspxで読むことができます。

于 2012-08-15T13:34:21.347 に答える