I'm trying to create a web application using ASP.NET MVC (though I'm still a beginner so I don't know much about C#, I only used VB.net). I want my ASP.NET MVC application to store the content of the HTML input tag like username and password to sign in to my application but it didn't work out.
(PS : I'm still a beginner so please make it as simple as it can get)
I already tried many tutorials before coming here, but none of them seems to work. Here's is the code I tried
// in the Model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MoviesApp.Models
{
public class Movie
{
public string id { get; set; }
public string name { get; set; }
}
}
// in the controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MoviesApp.Models;
namespace MoviesApp.Controllers
{
public class MoviesController : Controller
{
// GET: Movies
public ActionResult Random(string movieid, string moviename)
{
var movie = new Movie();
movie.id = movieid;
movie.name = moviename;
return View(movie);
}
}
}
//in views :
@model MoviesApp.Models.Movie
@{
ViewBag.Title = "Random";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<form method="post" action="Random">
<input type="text" name="movieid"/>
<input type="text" name="moviename"/>
<input type="submit" value="save" />
</form>