Channel 9 has just released a new video of 10-4, showing how to use this new function in ASP. NET 4.0.
The following is a piece of code displayed in the video. They used a classic example to show how to set Product. aspx? Category = Jerseys ing to Product/Jerseys. When using the ASP. NET Routing engine, we can add this ing to RouteTable in Application_Start:
RouteTable.Routes.Add("Product", new Route("Product/{name}", new PageRouteHandler("~/Product.aspx"))); |
Currently, to obtain bidirectional Routing Support, you must rewrite the URL of the Query String. However, when ASP. NET 4.0 is used, you can register the following expression builder ):
<system.web> <compilation> <expressionBuilders ...> <add expressionPrefix="RouteUrl" type="System.Web.Compilation.RouteUrlExpressionBuilder" /> <add expressionPrefix="RouteValue" type="System.Web.Compilation.RouteValueExpressionBuilder" /> </expressionBuilders> </compilation></system.web> |
The first expression is used to generate a URL, and the second is used to obtain the Route value. On the aspx page, you can use the $ symbol to access the expression:
<asp:HyperLink NavigationUrl="<%$ RouteUrl:RouteName=Product, name=Jerseys" Text="Jerseys" runat="server" /> |
To obtain the value in the name attribute, you can use the Route object instead of the Request object:
RouteData.Values["name"]; |
Or use the expression constructor:
Users can use the ASP. NET Routing engine and the new two-way support to decouple URLs from physical Web forms to support more friendly URLs for search engines.
- Details about. NET 4.0 code contract Components
- How to use MySQL database in. NET
- Analysis on Automatic Memory Management under the. NET Framework