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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ragini1
    New Member
    • Mar 2018
    • 1

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

    how to Get Data from the Request Object in ASP.NET MVC? describe data's?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    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.

    Comment

    • AjayGohil
      New Member
      • Apr 2019
      • 83

      #3
      fetch data from view to controller using Form Collection
      Example
      View File
      Code:
      @{
          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>
      pass this method in controller
      Code:
       public ActionResult Index()
              {
                  string fname = Request["fname"];
                  string lname = Request["lname"];
                  Response.Write("Your Full name is= " + fname + " " + lname);
      
                  return View();
      }

      Comment

      Working...