You need to make a HTML Form. A form will be rendered to the user, and when the user submits the form, the entered information will be sent back to the server.
This page is a decent tutorial on how to make a HTML form using ASP.NET MVC.
You have to create a model (class) with the properties you want the user to submit.
public class MyModel
{
public Int32 RandomNumber { get; set; }
}
Then, you will create two MVC actions. One, for requesting the form page, which will return a ViewResult with an empty model. The other will be the submit action, and will require a parameter with the model. This will be sent via the user's submission of the form:
public class FooController : Controller
{
[HttpGet]
public void Create()
{
return this.View("~/Views/FooController/Create.cshtml", new MyModel() );
}
[HttpGet]
public void Create(MyModel model)
{
//Do something with model information, such as save to database
}
}
The ViewResult will need to return a CSHTML page that creates a form for this model.
@model MyModel
@using(Html.BeginForm("Create", "Foo", FormMethod.Post))
{
@Html.TextBoxFor( m => m.RandomNumber )
}