Learn how to efficiently pass multiple parameters in URLs when developing ASP.NET Web API applications. Explore techniques such as using query parameters, route parameters, and model binding to handle complex data payloads.
This article describes how to pass multiple parameters in a query string or URL Here pass the parameter in the URL.
@{ ViewBag.Title = "Index"; } <h3>Passing multiple parameters in URL</h3> @using (Html.BeginForm("index", "Home")) { <a href="/home/MultipleParameter/?data1=678&data2=c-sharpcorner">Click here for passing the parameter</a> }
public ActionResult MultipleParameter(int data1, string data2) { ViewData["Data1"] = data1; ViewData["Data2"] = data2; return View(); }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MultipleParameterAPI.Controllers { public class HomeController : Controller { public ActionResult Index() { return View(); } public ActionResult MultipleParameter(int data1, string data2) { ViewData["Data1"] = data1; ViewData["Data2"] = data2; return View(); } } }
@{ ViewBag.Title = "MultipleParameter"; } <h2>MultipleParameter</h2> <h3><u>Values of multiple parameter is received</u></h3> <br /> <h3>Data1: @ViewData["Data1"]</h3> <br /> <h3>Data2: @ViewData["Data2"]</h3>
Hands on ASP.NET GridView