使用 UrlRewriting.Net 重写 Url 中的 PostBack Url [英] PostBack Url in Rewriting Url using UrlRewriting.Net

查看:42
本文介绍了使用 UrlRewriting.Net 重写 Url 中的 PostBack Url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我一些代码.当我使用 UrlRewriting.Net 在我的应用程序中重写 URL 时,它工作正常,但出现此错误:

<asp:LinkBut​​ton ID="LinkBut​​ton1" runat="server"PostBackUrl="Product/1/book.aspx">项目 1</asp:LinkBut​​ton>

网址为: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&amp;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&amp;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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆