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

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"

        Charts area
        1. cached for 10 minutes by default
        2. cached for 180 minutes
<img src="/Home/MyChart" />
    <img src="/Home/MyCachedChart" 

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.

See also

One thought on “ASP.NET MVC 3 Beta: Razor views support comments now

  • IBM says:

    I think that everything published made a ton of sense.
    However, think about this, suppose you added a little
    content? I am not saying your content is not solid, but suppose you added a title to possibly grab a person’s attention? I mean ASP.NET MVC 3 Beta:
    Razor views support comments now | Gunnar Peipman – Programming Blog is a
    little vanilla. You ought to look at Yahoo’s front page and see how they create article titles
    to get viewers to click. You might add a related video or
    a related pic or two to get people excited about everything’ve got to
    say. In my opinion, it could make yoiur posts a little
    bit more interesting.

Leave a Reply

Your email address will not be published. Required fields are marked *