MVC 5 Routing with multiple optional parameters

MVC 5 Routing with multiple optional parameters

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>

}

ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.