0

Please help me a bit code. When i using UrlRewriting.Net to Rewrite URL in my app it works fine but i got this error:

<asp:LinkButton ID="LinkButton1" runat="server"
 PostBackUrl="Product/1/book.aspx">Item 1</asp:LinkButton>

the url is: http://localhost/Product/1/book.aspx and when i click back to home page the url is like this: http://localhost/**Product/1**/Home.aspx

this is my web.config

<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>
.....
 </system.web>

<rewriter>
<rewrite url="~/Home.aspx" to="~/vi/Default.aspx"/>
<rewrite url="~/Product/(.*)/(.*).aspx" to="~/ProductsPage.aspx?catID=$1&amp;title=$2"/>
</rewriter>
</configuration>

Thanks.......

Balanivash
  • 6,709
  • 9
  • 32
  • 48

1 Answers1

0

Not sure why you have the ASPX in the URI any more. The idea behind routing is you take a friendly URI:

 http://localhost/Product/1

And the routing engine routes to book.aspx. The fact your URI looks like:

http://localhost/Product/1/book.aspx 

indicates you are not routing properly.

Gregory A Beamer
  • 16,870
  • 3
  • 25
  • 32
  • Thank for your answer, but i am still wondering the url when i clicked to return to home page should be: >http:localhost/Home.aspx instead of: >http:localhost/Product/1/book.Home.aspx – Nam Nguyen Jun 28 '11 at 05:26
  • Like all URL rewriters, the pattern is Regex and should not require .aspx anywhere in the url attribute of a rule. The config documentation shows this (http://urlrewriter.net/index.php/support/configuration). I am not sure how you are setting up the URI to redirect back (you have no code samples), but remove the ASPX and allow the routing rule to map the SEO friendly URI (http://mysite/product/1) to the proper page (http://mysite/product.aspx?id=1). – Gregory A Beamer Jun 28 '11 at 15:57
  • Thx for your all anwser..., it's really work! my app is working now it's because i'm using the control of html just replace by the control of asp.net: --> ... – Nam Nguyen Jun 28 '11 at 16:47
  • Glad it is working. I figured it was something with the way the link was created. – Gregory A Beamer Jun 28 '11 at 17:47