2

방금 ​​Urlrewriter.net에서 샘플을 설치했지만, 내 문제를 해결하기위한 규칙을 알아낼 수 없습니다.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> 

이것이 첫 번째 단계입니다. 더 이상적으로 페이지 id는 데이터베이스 에 전달해야하고, ID 대신 페이지 이름을 반환하고, URL은 다음과 같이 을 찾고 결국해야합니다

http://localhost/UrlRewriteTest/thename/ 

안부를.

답변

1

URL 재 작성 @http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx에 대한 Scott Guthrie의 기사를 읽을 수 있습니다.

+0

안녕하세요. 링크를 이용해 주셔서 감사합니다. 이미 기사를 읽었으며 꽤 잘 설명되어 있지만 구체적인 문제를 해결할 수없는 것 같습니다. 나는 URL 재 작성에 완전히 익숙하지 않기 때문에 나는 아직 빛을 보지 못했다. .. – micknt

+0

안녕하십니까, [소스 코드] (http://www.scottgu.com/blogposts/urlrewrite/UrlRewrite_HttpModule1)를 다운로드 해 보았습니다. .zip)을 수정하고 필요에 맞게 조정하십시오. – Esteban

+0

안녕하세요, 저는 실제로 시도했지만 여기서는 실제로 작동해야하는 매우 간단한 예가 있습니다. 내가 잘못하고있는 일이나 적용 할 마법을 볼 수 있습니까? https://dl.dropbox.com/u/17202645/UrlRewrite_HttpModule1_SimpleTest.zip – micknt