Source/Routing/MqttRouteTableFactory.cs
/// <summary>
/// Given a route template string suchs a "[controller]/[action]" replace the tokens with the values provided.
/// /// Controllers with a suffix of "Controller" will be chopped to exclude the word Controller from the
/// returns route string.
/// </summary>
/// <param name="template">Template string</param>
/// <param name="controllerName">Name of the controller object</param>
/// <param name="actionName">Name of the action method</param>
/// <returns>String with replaced values</returns>
Given a route template string suchs a "[controller]/[action]" replace the tokens with the values provided.
Controllers with a suffix of "Controller" will be chopped to exclude the word Controller from the
returns route string.
Given a route template string suchs a " [ controller ] / [ action ] " replace the tokens with the values provided . Controllers with a suffix of " Controller " will be chopped to exclude the word Controller from the returns route string .
private static string ReplaceTokens(string template, string controllerName, string actionName)
        {
            return template
                .Replace("[controller]", controllerName.EndsWith("Controller") ? controllerName.Substring(0, controllerName.Length - 10) : controllerName)
                .Replace("[action]", actionName);
        }
private static string ReplaceTokens ( string template , string controllerName , string actionName ) { return template . Replace ( " " , controllerName . EndsWith ( " " ) ? controllerName . Substring ( 0 , controllerName . Length - 10 ) : controllerName ) . Replace ( " " , actionName ) ; }
Given a route template string suchs a "[controller]/[action]" replace the tokens with the values provided.
Given a route template string suchs a " [ controller ] / [ action ] " replace the tokens with the values provided .
// In a future enhancement, we may allow escaping tokens with a "[[" to have feature parity with AspNet routing. // Strip "Controller" suffix from controller name if needed
String with replaced values
String with replaced values
template
string
None
controllerName
string
Name of the controller object
Name of the controller object
actionName
string
Name of the action method
Name of the action method