I am using Attribute based routing in a MVC application. My Code is -
[RouteArea("MasterData")]
[RoutePrefix("BrandFacilityShipmentMaintenance")]
public class BrandFacilityShipmentMaintenanceController : Controller
{
[Route("Index")]
public ActionResult Index()
{
}
}
I am trying to hit the url with variabale parameters like
/MasterData/BrandFacilityShipmentMaintenance/Index
/MasterData/BrandFacilityShipmentMaintenance/Index/1156?pid=1120
/MasterData/BrandFacilityShipmentMaintenance/Index/1156?pid=1120&fname=Brand+Facility+Shipment+Maintenanca
/MasterData/BrandFacilityShipmentMaintenance/Index/1156?pid=1120&fname=Brand+Facility+Shipment+Maintenanca&isReffered=false
But it says resource not found. These all urls hit same Index action in Conventional based routing. What should I change to make it work in attribute based routing.
AreaRegistration.cs -
public override void RegisterArea(AreaRegistrationContext context)
{
context.Routes.MapMvcAttributeRoutes();
context.MapRoute(
"Masterdata_default",
"Masterdata/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}