Understanding Razor Views

Possibly save 1 hour of your time: The following are some code tips on what you can do on a razor view. Razor view has a .cshtml file extension.

The following shows the use of no Layout (similar to master page concept). If you didn’t set Layout to empty, it will default to use Views/Shared/_Layout.cshtml. You can use ViewBag to pass data between controller and view.

@{
ViewBag.Title = "Map";
Layout = "";
}

The following shows how you can include a Javascript and CSS reference in the element.

@section head {
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.41.0/mapbox-gl.js'></script>
		<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.41.0/mapbox-gl.css' rel='stylesheet' />
}

Book: Instant Razor View Engine How-to

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s