And ignore route rule like ("{resource}.axd/{*pathInfo}") contains special names like {resource} and {*pathInfo}. So where is a list of these special names? And what the start(*) means in {*pathInfo").
Sorry for this naive question. But I search on web for hours but no answers found.
Your reply provide helpful clue for me. Thank you. I have something still need to clarify:
Let's still take URL pattern "{resource}.axd/{*pathInfo}" as an example. The first placeholder {resource} is just named lable to contain all characters befor .axd and {*pathInfo} used for contain anyting after. They are neither hard coded
special names.
The star(*) in {*pathInfo} functions like in RegEx to tolerate the case when there is nothing after .axd, such as mach an url
/c/xyz.axd, right?
But for {resource}, there is no chance for the partial url before .axd to be a empty string, at least it contains slash or file name, so star(*) is unnecessary for it. Right?
If above are both right, on the other hand like a routing rule like:
{controller}/{action}/{id}
Are {controller} and {action} hard code place holders for mvcHttpHandler for match the controller class and action method names? Or just the positioning works? I mean mvcHttpHandler just take the first place holder as controller name and
second place holder as action name, and the rest are parameters name, or the naming matter?
Are {controller} and {action} hard code place holders for mvcHttpHandler for match the controller class and action method names?
Yes, they are. You need to always use "controller" or "action" or "area" to get the respective value.
duxinrun
Or just the positioning works? I mean mvcHttpHandler just take the first place holder as controller name and second place holder as action name, and the rest are parameters name, or the naming matter?
No they can come in any order but while matching the url, MVC will match based on the route definition position, so if "controller" is coming at first place then mvc will try to get the controller from first argument.
duxinrun
or the naming matter?
Yes, it matters, MVC matches the parameters based on names. Look at the default route definition, it matches, controller, action and id based on name.
Basically MVC parses the url into key value pair based on the route definition and pass it to handler.
duxinrun
Member
10 Points
13 Posts
Where to find a list of special names for route rule string?
Nov 25, 2012 09:11 AM|LINK
Hi all,
And ignore route rule like ("{resource}.axd/{*pathInfo}") contains special names like {resource} and {*pathInfo}. So where is a list of these special names? And what the start(*) means in {*pathInfo").
Sorry for this naive question. But I search on web for hours but no answers found.
urenjoy
Star
12027 Points
1807 Posts
Re: Where to find a list of special names for route rule string?
Nov 25, 2012 09:18 AM|LINK
Have a look at following thread:
http://stackoverflow.com/questions/3156204/can-someone-explain-asp-net-routing-syntax-to-me
duxinrun
Member
10 Points
13 Posts
Re: Where to find a list of special names for route rule string?
Nov 25, 2012 09:40 AM|LINK
Hi urenjoy,
Your reply provide helpful clue for me. Thank you. I have something still need to clarify:
Let's still take URL pattern "{resource}.axd/{*pathInfo}" as an example. The first placeholder {resource} is just named lable to contain all characters befor .axd and {*pathInfo} used for contain anyting after. They are neither hard coded special names.
The star(*) in {*pathInfo} functions like in RegEx to tolerate the case when there is nothing after .axd, such as mach an url /c/xyz.axd, right?
But for {resource}, there is no chance for the partial url before .axd to be a empty string, at least it contains slash or file name, so star(*) is unnecessary for it. Right?
If above are both right, on the other hand like a routing rule like:
{controller}/{action}/{id}
Are {controller} and {action} hard code place holders for mvcHttpHandler for match the controller class and action method names? Or just the positioning works? I mean mvcHttpHandler just take the first place holder as controller name and second place holder as action name, and the rest are parameters name, or the naming matter?
Thank you for your help.
CPrakash82
All-Star
18168 Points
2833 Posts
Re: Where to find a list of special names for route rule string?
Nov 25, 2012 04:30 PM|LINK
Yes, they are. You need to always use "controller" or "action" or "area" to get the respective value.
No they can come in any order but while matching the url, MVC will match based on the route definition position, so if "controller" is coming at first place then mvc will try to get the controller from first argument.
Yes, it matters, MVC matches the parameters based on names. Look at the default route definition, it matches, controller, action and id based on name.
Basically MVC parses the url into key value pair based on the route definition and pass it to handler.
duxinrun
Member
10 Points
13 Posts
Re: Where to find a list of special names for route rule string?
Nov 28, 2012 03:38 AM|LINK
Thank you for your help.