<form asp-controller="Role" asp-action="Create" asp-route-returnurl="@ViewBag.ReturnUrl" method="post" class="form-horizontal" role="form">
<div class="form-group">
<label asp-for="@Model.Name" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="@Model.Name" class="form-control" />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</form>
[HttpPost]
public ActionResult Create(string rolename)
{
try
{
this.context.Roles.Add(new IdentityRole()
{
Name = rolename
});
this.context.SaveChanges();
ViewBag.ResultMessage = "Role created !";
return RedirectToAction("Index");
}
catch
{
return this.View();
}
return this.View();
}
[HttpPost]
public ActionResult Create(ModelClass model)
{
if (!ModelState.IsValid)
{
return View(model);
}
..............................................
}
public class ModelClass
{
publis string Name { get; set; }
}