使用 UrlRewriting.Net 重写 Url 中的 PostBack Url [英] PostBack Url in Rewriting Url using UrlRewriting.Net
问题描述
请帮我一些代码.当我使用 UrlRewriting.Net 在我的应用程序中重写 URL 时,它工作正常,但出现此错误:
<asp:LinkButton ID="LinkButton1" runat="server"PostBackUrl="Product/1/book.aspx">项目 1</asp:LinkButton>
网址为:http://localhost/Product/1/book.aspx
当我点击回到主页时,网址是这样的:http://localhost/**Product/1**/Home.aspx
这是我的 web.config
<预><代码><配置><configSections><部分名称=重写器"要求权限=假"type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/></configSections>……………………<system.web><http模块><add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/></httpModules>.....</system.web><重写器><rewrite url="~/Home.aspx" to="~/vi/Default.aspx"/><rewrite url="~/Product/(.*)/(.*).aspx" to="~/ProductsPage.aspx?catID=$1&title=$2"/></rewriter></配置>谢谢......
不确定为什么 URI 中不再包含 ASPX.路由背后的想法是您采用友好的 URI:
http://localhost/Product/1
路由引擎路由到 book.aspx.您的 URI 如下所示:
http://localhost/Product/1/book.aspx
表示您没有正确路由.
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&title=$2"/>
</rewriter>
</configuration>
Thanks.......
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.
这篇关于使用 UrlRewriting.Net 重写 Url 中的 PostBack Url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!