Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

ASP.NET MVC 3 Beta: Razor views support comments now

DZone's Guide to

ASP.NET MVC 3 Beta: Razor views support comments now

·
Free Resource

Sometimes we need server-side comments in ASP.NET MVC views. New version of Razor view engine supports comments in views and in this posting I will show you example of view with multiline comments.

I will use the view from my ASP.NET MVC charts caching example and add one multiline comment to this view. Note that comments are put between @* and *@ marks.

@{
    View.Title = "Home Page";
}
 
<h2>@View.Message</h2>
<p>
    @* 
        Charts area 
        -----------
        1. cached for 10 minutes by default
        2. cached for 180 minutes
    *@
    <img src="/Home/MyChart" />
    <img src="/Home/MyCachedChart" />
</p>

NB! This is only example. Don’t write long stories to the comments of your views. Add comments only if it is necessary and if it helps UI developers to communicate better with the presentation layer or model.

Topics:

Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}