0

I'm trying to use the following routing which is used in the procject for other routings, but i cant get a hang of it.

<route name="GarageDetails" url="garage/car/details/{CarId}" physicalFile="~/Garage/GarageCarDetails.aspx">
        <constraints>
          <add placeholder="CarId" pattern="\d+"></add>
        </constraints>
      </route>

In my GarageCarDetails i'm trying to fetch the querystring with

CarId = Convert.ToInt32(Request.QueryString["CarId"]);

but the request wont get it at all.

If i use anchors with GarageCarDetails.aspx?CarId=xxx it works fine.

My links now should look like /garage/car/details/xxx

Anyone know how to do this?

4

1 回答 1

1

使用RouteData.Values["CarId"]而不是Request.QueryString["CarId"].

RouteData.Values 属性:获取路由的 URL 参数值和默认值的集合。

于 2012-11-11T15:36:33.837 回答