complez
complez

Reputation: 8322

asp.net routing in webform - how get route data

i put this in Global.asax.cs

routes.MapWebFormRoute("Page", "Page/{*anything}", "~/Page.aspx", false);

how i can get value of {*anything} in Page.aspx

i'm using WebFormRouting from codeplex

Upvotes: 4

Views: 11158

Answers (1)

Robert Harvey
Robert Harvey

Reputation: 180777

For WebFormRouting, you should check out this blog post by Phil Haack:

Using Routing With WebForms
http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx

He says that, if your Web Form Page implements the IRouteable interface, the WebFromRouteHandler class can pass it the RequestContext. Once this is done, you should be able to:

string value = Page.RouteData.Values["anything"]; 

There is a sample project at the blog post.

Upvotes: 8

Related Questions