0

我正在尝试在应用程序 global.asax 上定义 MapPageRoute,但我的问题是我无法使用查询字符串将特定 URL 路由到物理文件。

例如,我想将http://mysite.com/Apple重定向到http://mysite.com/product.aspx?id=95。到目前为止,我设法实现的是,如果用户要求 ./Apple,他将被重定向到 ./product.aspx 但我无法传递查询字符串。

期待您的评论。

4

1 回答 1

0

试试这个:

if (Page.RouteData.Values["Apple"] != null)
{
    int appleID = Convert.ToInt32(Page.RouteData.Values["Apple"]);
    Response.Redirect("~/product.aspx?id=" + appleID.ToString(), true); 
}
于 2012-06-28T04:55:04.967 回答