'Url.Action not able to match a route

in my Mvc controller I have the following action with a defined route

 [HttpGet]
    [Route("OrderLineSchedule/{salesOrderId}/{webOrderId}/{orderLineNumber}")]
    public async Task<ActionResult> OrderLineSchedule(string salesOrderId, int? webOrderId, int orderLineNumber)
    { 
//code 
    }

In one view I have the following link trying to cree the url using with Html.Action helper method.

 <a href='@Url.Action("OrderLineSchedule", "Orders", new { area = "account", SalesOrderId = Model.SalesOrderId, WebOrderId = Model.WebOrderId, OrderLineNumber = Model.OrderLineNumber})' id="lnkOrderLineSchedule">@Model.Quantity @Model.ActivityName</a>

The problem is - only in one occasion when Model.SalesOrderId property is null - in this case Url.Action is not able to construct any url pointing to this action. I will appreciate any hep



Solution 1:[1]

Make sure MapMvcAttruteRoute before MapRoute in RegisterRoutes. and your Controller names should be OrdersController

MapMvcAttruteRoute - Location

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 thisisnabi