I have a LogoutModel with one attribute. I want my HomeController to change this value and for the View to then show this value but it doesn’t seem to be working. When the Logout View is displayed it shows: ‘Goodbye Html.LabelFor(m => m.PreviouslyLoggedInUsername)’
LogoutModel:
public class LogoutModel
{
public string PreviouslyLoggedInUsername { get; set; }
}
HomeController:
public ActionResult Logout(HomeModels.LogoutModel model)
{
model.PreviouslyLoggedInUsername = previousLoggedIn;
return View(model);
}
View:
@using Ecommerce.Models
@model HomeModels.LogoutModel
@{
ViewBag.Title = "Logout";
Layout = "~/Views/Shared/Master.cshtml";
}
<h2>You have been logged out.</h2>
@using (Html.BeginForm())
{
<table>
<tr>
<td>
<label>Goodbye </label>
Html.LabelFor(m => m.PreviouslyLoggedInUsername)
</td>
</tr>
</table>
}
You need to place an
@symbol before theHtml.LabelFor...For reference, here’s the Razor syntax quick guide.