I'm having a problem using parameters in Durandal for an ASP.NET MVC application...
I use MVC Route Attributes, for example:
[Route("admin/pages")]
, [Route("admin/blog")]
, etc..
And I integrate Durandal as follows:
main.js:
app.start().then(function() {
viewEngine.viewExtension = '/';
viewLocator.convertModuleIdToViewId = function (moduleId) {
return moduleId.replace('viewmodels', '');
};
app.setRoot('viewmodels/admin/shell', 'entrance');
});
This works nicely, as the viewId ends up matching the MVC route.
However, I now face a serious problem with trying to use parameters in the routes. For example, I have one route as follows:
[Route("admin/localization/localizable-strings/{languageId}")]
and my Durandal route for this is:
localization/localizable-strings/:languageId
Example anchor tag:
<a href="/admin/#localization/localizable-strings/1" class="btn btn-primary btn-xs">Localize</a>
This doesn't work, as it seems Durandal doesn't pass the parameter to the server. It simply retrieves the HTML from /admin/localization/localizable-strings
which returns a 404 page because no parameter was passed to the MVC action.
What are my options here?