I don't know if I have before, but I have to express my love for the Razor syntax. Working C# code directly into HTML code is just wonderful.
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
Character
</th>
<th>
Title
</th>
<th>
Gil
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.CharacterName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Gil)
</td>
<td>
@if (User.Identity.IsAuthenticated)
{
@Html.ActionLink("Edit", "Edit", new { id = item.CharacterId })
}
@Html.ActionLink("Details", "Details", new { id = item.CharacterId })
@if (User.Identity.IsAuthenticated)
{
@Html.ActionLink("Delete", "Delete", new { id = item.CharacterId })
}
</td>
</tr>
}
</table>
Means I am able to work in foreach loops and if/then statements into HTML code and use C# functions and types, it's so nice not having to write in separate blocks of code but integrate it all together. I also like that it's intelligent enough to know when a type end, so if I wanted to, I could write this:
<h2>@ViewBag.UserName's Characters</h2>
Without it causing an error because the parser is including the 's when debugging and seeing it as an invalid type. You might expect to have to put the variable inside of a tag normally, but nope, it's pretty seamless.
I don't think I can go back to using the alternatives.