@foreach(var bid in bids) {
@bid.Username
@bid.Amount
}
Last Bid Amount: @bid.Amount
Code blocks are a means to execute code within a template and do not render anything to the view. In direct contrast to the way that code nuggets must provide a return value for the view to render, the view will completely ignore values that a code block returns.
Layouts
Razor offers the ability to maintain a consistent look and feel throughout your entire website through layouts. With layouts, a single view acts as a template for all other views to use, defining the site-wide page layout and style.
A layout template typically includes the primary markup (scripts, CSS stylesheets, and structural HTML elements such as navigation and content containers), specifying lo cations within the markup in which views can define content. Each view in the site then refers to this layout, including only the content within the locations the layout has indicated.
Take a look at a basic Razor layout file (_Layout.cshtml):
28 | Chapter 1: Fundamentals of ASP.NET MVC