Sitefinity’s URL handling capabilities are built on the ASP.NET Routing Engine (formerly known as the ASP.NET MVC Routing Engine). When you are working in pure or hybrid mode, the route is picked up by the page. The page then constructs dynamically new routes for the MVC based widgets, which may or may not respond to it. If at least one of the widgets can handle the route data, page will render - otherwise you'll get 404. In a word - you must use route registrations only for classic MVC (side by side apps) mode. For more information about the different modes, read For developers: MVC modes.
For example, take the following action:
In order to invoke it you will need to specify both parameters in the URL - /<page url>/details/<page>/<name>. The parameters should be in the same order as they are in the action method declaration. If the parameters are swapped (/<page url>/details/<name>/<page>) the invocation will result in displaying an error.
When the ActionLink helper method is used, the order of the parameters is not important, as in the following sample:
Both invocations will generate correct URL - /<page url>/Details/3/Some name.
Note: If any of the required parameters is missing, the generated URL will have no parameters specified and will not be correct - /<page url>/Details/, because no action can be found with the provided parameters.
To mark any of the parameters as not required, you need to set default value for it or to make it nullable (only for value types). For example, the following URL - /<page url>/Details/3, will successfully match and execute the action with declaration:
In order to skip both parameters, you must declare the action in one of the following ways:
NOTE: All optional parameters must be after the required ones.
Back To Top