how to Get Data from the Request Object in ASP.NET MVC? describe data's?
how to Get Data from the Request Object in ASP.NET MVC?
Collapse
X
-
The controller has a request property that returns a HttpRequestBase that has a number of properties and methods that you can use to find information about the request.
See the link I posted to the documentation to learn more. -
fetch data from view to controller using Form Collection
Example
View File
pass this method in controllerCode:@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>Index</title> </head> <body> <form method="get" action="new\Index"> <table> <tr> <td>Enter First Name</td> <td><input type="text" id="fname" name="fname" /></td> </tr> <tr> <td>Enter Last Name</td> <td><input type="text" id="lname" name="lname" /></td> </tr> <tr> <td></td> <td><input type="submit" /></td> </tr> </table> </form> </body> </html>Code:public ActionResult Index() { string fname = Request["fname"]; string lname = Request["lname"]; Response.Write("Your Full name is= " + fname + " " + lname); return View(); }Comment
Comment