Lets say I have this sql server table :
id Name Band
--------------------
1 John Beatles
2 Paul Beatles
3 George Beatles
4 Ringo Beatles
5 Jim Doors
I want to have a person details page like :
http://localhost/Music/Beatles/Paul
and I want to treat is as :
http://localhost/Details.aspx?id=2
And so- I'm writing this code to register a simple route :
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapPageRoute("MyRoute", "Music/{Band}/{Name}", "~/Details.aspx");
}
But I don't understand :
When Asp.net get http://localhost/Music/Beatles/Paul
, how does he know it knows that Paul's value is 2
?
Are you telling me that each time asp.net encounters Paul
he should go to DB and scan a pre-defined unique column (Name
in this case) and get it's column ID
value?
Or Should I inject Paul's value into the url like SO doing :
http://stackoverflow.com/questions/13938994/jquery-conditional-validation-based-on-select-text
^
|
---------------------------------------
which will be in my case :
http://localhost/Music/Beatles/2/Paul