Before proceeding, I recommend you to read the previous article of this series i.e. Create First Application in ASP.NET MVC 4.0. In this article, we will learn how to pass parameter or Query String in an Action Method in ASP.NET MVC.
Let's Begin:
- Create a new ASP.NET MVC 4 Empty Project.
- Add a controller and name it HomeController, then Add Index Action Method to it. If you don't know how to create or how to add controller read it here.
- Pass parameter in Index Action Method.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace PassParameter.Controllers
- {
- public class HomeController : Controller
- {
- //
- // GET: /Home/
- public string Index(string id)
- {
- return "ID =" + id;
- }
- }
- }
In the above code, we have passed a parameter named as the id of string data type. Now Build & Run the application and open http://localhost:13923/Home/Index/10 link in the URL by passing the parameter to Index Action Method of Home Controller.
Preview:
Passing Multiple Parameter in Index Action Method:
In the above example, we saw how to pass single parameter in Action Method, but there are many situations when we have to pass more than one parameter. Let's see how to do this in ASP.NET MVC.
Passing Multiple Parameter in Index Action Method:
In the above example, we saw how to pass single parameter in Action Method, but there are many situations when we have to pass more than one parameter. Let's see how to do this in ASP.NET MVC.

Cemal SenerPosted Apr 6, 2021, 4:44 AM
Value of this article is of being simple but having importan keys, would be better if you show MapRoute aspects too, thanks for your effort...
Shawn FaciniPosted Apr 30, 2019, 4:00 PM
How would i do it from a email to a web page?
SURAJ SHARMAPosted Mar 28, 2019, 7:38 AM
Hello, my application requirement is that I need to post the data back to the same page using query strings instead of passing it through POST Request Body. I don't want to se Defauldt Model Binder to accept my data. How to achieve it?
Fernando VerasPosted Oct 30, 2018, 12:46 PM
Works fine! Thanks!
Dinesh KumarPosted May 30, 2018, 4:03 AM
The example I am running the querystring value not coming, i m new mvc please help with us
Jay RakshitPosted Apr 7, 2018, 6:31 AM
Can you share the example of one get method? sometimes it can call with parameter else without a parameter.
Balamurugan APosted Jan 9, 2018, 2:23 AM
Thank you. it is working perfectly
Neeraj GuptaPosted Apr 9, 2017, 8:07 AM
I am getting ; expected error while doing as above please suggest me
Ankur ChaturvediPosted Dec 5, 2016, 1:10 PM
Thank you Good Explanation
Delpin Susai RajPosted Aug 28, 2016, 11:12 AM
Good
kalu singh raoPosted Jun 14, 2016, 1:32 AM
Nice Artricles
Thiruppathi RPosted May 23, 2016, 3:20 PM
Nice info..
Mohammad KhalidPosted Apr 14, 2016, 3:00 AM
Nice stuff.......
Anoop Kumar SharmaPosted Oct 18, 2015, 11:04 AM
Thanks Santhakumar Munuswamy..!!
Santhakumar MunuswamyPosted Oct 18, 2015, 4:45 AM
Good one
Anoop Kumar SharmaPosted Oct 11, 2015, 10:26 AM
Thanks Gowtham K..!!
Gowtham KPosted Oct 11, 2015, 8:57 AM
Good One
Anoop Kumar SharmaPosted Oct 10, 2015, 12:41 PM
Thanks Harshad Pansuriya..!! :-)
Anoop Kumar SharmaPosted Oct 10, 2015, 12:41 PM
Thanks Rakesh Chavda..!! :-)
Anoop Kumar SharmaPosted Oct 10, 2015, 12:40 PM
Thanks Nilesh Jadav..!! :-)
Anoop Kumar SharmaPosted Oct 10, 2015, 12:39 PM
Thanks Sujeet Suman..!! :-)
Anoop Kumar SharmaPosted Oct 10, 2015, 12:38 PM
Thanks Mukesh Kumar..!!
Ankur ChaturvediPosted Oct 10, 2015, 7:04 AM
Good article
Harshad PansuriyaPosted Oct 10, 2015, 2:43 AM
Nice one
RakeshPosted Oct 10, 2015, 2:09 AM
Good one
Nilesh JadavPosted Oct 10, 2015, 1:49 AM
Thanks for share
Sujeet SumanPosted Oct 9, 2015, 11:51 PM
Good Sharing.................
Mukesh KumarPosted Oct 9, 2015, 11:39 PM
Nice One