I saw people use asterisk sign at the time of routing in webform. i just do not understand the importance of Asterisk sign like below one
routes.MapPageRoute(
"View Category", // Route name
"Categories/{*CategoryName}", // Route URL
"~/CategoryProducts.aspx" // Web page to handle route
);
what is the meaning of asterisk sign and also tell me what kind of situation i should use asterisk sign like above.
"Categories/{*CategoryName}"
it would be better if anyone come with small sample code of using Asterisk sign just to show the importance & use of asterisk sign in real life apps.
Since this was the first resource Google returned me for variable number of parameters I added below example from MSDN so future readers would find the solution here.
The following example shows a route pattern that matches an unknown number of segments.
query/{queryname}/{*queryvalues}
Case 1
URL :
/query/select/bikes/onsale
Resolved Parameter Values:
Case 2
URL :
/query/select/bikes
Resolved Parameter Values:
Case 3
URL :
/query/select
Resolved Parameter Values:
Reference: MSDN: Handling a Variable Number of Segments in a URL Pattern
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With