I currently get the error "The Resource cannot be found" when trying to access a View.
The View I am trying to open is called "Register". The Controller(AccountController) has the ActionResult Method "Register" implemented.
The same Controller contains a "Login" View that I can access without any problems.
The URLS I am trying to call:
localhost:port/Account/Login <- Works localhost:port/Account/Register <- Doesnt work
Controller Method:
[HttpPost]
public ActionResult Register(LoginModel model)
{
if(ModelState.IsValid)
{
movieEntities db = new movieEntities();
var newUser = db.users.Create();
var encrypPass = Helpers.SHA256.Encode(model.Passwort);
var user = model.UserName;
newUser.user_name = user;
newUser.user_passwdhash = encrypPass;
db.users.Add(newUser);
db.SaveChanges();
return RedirectToAction("Index", "Home");
}
return View(model);
}
View:
@model MovieDatabase.Models.LoginModel
@{
ViewBag.Title = "Register";
}
<h2>Register</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>LoginModel</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.UserName, htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserName, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.UserName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Passwort, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Passwort, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Passwort, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Register="btn btn-default" />
</div>
</div>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
I tried cleaning, rebuilding the solution, renaming the View, renaming the method and creating them new... What am I missing here?