Databases Reference
In-Depth Information
RouteTable.Routes.Add(new DynamicDataRoute(“Product”)
{
Action = PageAction.Details,
Table = “Products”
});
Based on this route definition, the Dynamic Data web application can use the following
URL:
http://localhost/Product?ProductID=1
instead of the more verbose and less user-friendly:
http://localhost/Products/Details.aspx?ProductID=1
URL Parameters Versus Query Parameters
URL parameters are an alternative to the Query parameters used by traditional ASP.NET
WebForms applications. Whereas the traditional query parameters require both names and
values to be present in the query string, the URL parameters allow web applications to
determine parameter names automatically, based on the position of their values in the
URL. Consider the following route, which replaces the ProductID query parameter with a
positional URL parameter:
RouteTable.Routes.Add(new DynamicDataRoute(“Product/ {ProductID} ”)
{
Action = PageAction.Details,
Table = “Products”
});
This route definition allows the web application to implement the product catalog
without query parameters and support URLs similar to that shown below. This not only
makes the URLs shorter and easier for users to read, but also makes it easier for the search
engines to index dynamic pages, which is very important for public-facing web sites:
http://localhost:49212/Product/3
Dynamic Data still supports traditional Query parameters, which you can activate by regis-
tering a route that does not include any URL parameters and does not specify parameter
values explicitly:
RouteTable.Routes.Add(new DynamicDataRoute(“Dynamic”));
The route registered just shown makes Dynamic Data use URLs that look like this instead:
http://localhost/Dynamic?Table=Products&Action=List
 
Search WWH ::




Custom Search