MVC 5 Routing with multiple optional parameters
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{Action}/{id}/{type}",
defaults: new { controller = "Home", action
= "Index", id = UrlParameter.Optional, type = UrlParameter.Optional }
);
}
}
/// <summary>
/// This is used to display data for product servicess.
/// </summary>
/// <returns></returns>
public ActionResult ServiceDetails(int id, int type)
{
ViewBag.ProDetail = BindTiels(id,
type);
return View();
}
private List<proc_Provisioning_Details_Result> BindTiels(int id, int type)
{
return new
ConnectRepository().GetProvisioning(_userSession.CompanyID,
_userSession.TenantID, id, type);
}
HTML Code
@foreach (var pro in ViewBag.ProvisionServices)
{
<a href="/Connect/ServiceDetails/@pro.ID/@pro.Type " class="list-group-item"></a>
}