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

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book