By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,685 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,685 IT Pros & Developers. It's quick & easy.

how to Get Data from the Request Object in ASP.NET MVC?

P: 1
how to Get Data from the Request Object in ASP.NET MVC? describe data's?
Mar 17 '18 #1
Share this Question
Share on Google+
2 Replies


Frinavale
Expert Mod 5K+
P: 9,731
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.
Mar 19 '18 #2

P: 16
fetch data from view to controller using Form Collection
Example
View File
Expand|Select|Wrap|Line Numbers
  1. @{
  2.     Layout = null;
  3. }
  4.  
  5. <!DOCTYPE html>
  6.  
  7. <html>
  8. <head>
  9.     <meta name="viewport" content="width=device-width" />
  10.     <title>Index</title>
  11. </head>
  12. <body>
  13.     <form method="get" action="new\Index">
  14.         <table>
  15.             <tr>
  16.                 <td>Enter First Name</td>
  17.                 <td><input type="text" id="fname" name="fname" /></td>
  18.             </tr>
  19.              <tr>
  20.                 <td>Enter Last Name</td>
  21.                 <td><input type="text" id="lname" name="lname" /></td>
  22.             </tr>
  23.              <tr>
  24.                 <td></td>
  25.                 <td><input type="submit"  /></td>
  26.             </tr>
  27.         </table>
  28.     </form>
  29. </body>
  30. </html>
pass this method in controller
Expand|Select|Wrap|Line Numbers
  1.  public ActionResult Index()
  2.         {
  3.             string fname = Request["fname"];
  4.             string lname = Request["lname"];
  5.             Response.Write("Your Full name is= " + fname + " " + lname);
  6.  
  7.             return View();
  8. }
Apr 1 '19 #3

Post your reply

Sign in to post your reply or Sign up for a free account.