I noticed that I find it strange behavior with T4MVC. In particular, I am trying to create an ActionLink (using an HtmlHelper) for an action where the optional parameter value is null. This works great most of the time. However, if the current route is the same for which ActionLink is created, and the OptionParameter parameter is nonzero, as a result, ActionLink will indicate the value of the optional parameter from the current route context.
This verbose explanation, I think the code will help clarify.
controller
public virtual ActionResult Today(int? lineNumber = null)
{
return Index(DateTime.Today, DateTime.Today, lineNumber);
}
Route
context.MapRoute(
"TodaysProductionSchedules",
"Production/{Controller}/Today/{lineNumber}",
new
{
area = AreaName,
controller = MVC.Production.ProductionSchedules.Name,
action = MVC.Production.ProductionSchedules.ActionNames.Today,
lineNumber = UrlParameter.Optional
});
Razor
@Html.ActionLink("Show Today", MVC.Production.ProductionSchedules.Today(null))
, , , . , null ( ), lineNumber .
, T4MVC, codeplx T4MVC. !