Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8453133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:41:23+00:00 2026-06-10T11:41:23+00:00

How to write a comment in a MVC view, that won’t be transmitted to

  • 0

How to write a comment in a MVC view, that won’t be transmitted to the final HTML (i.e.,to browser, to response). One can make a comment with:

<!--<a href="/">My comment</a> -->

but, it is visible in the page source code in browser.

Is it possible to leave comments in ‘.cshtml’ files only for internal use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:41:24+00:00Added an answer on June 10, 2026 at 11:41 am

    Note that in general, IDE’s like Visual Studio will markup a comment in the context of the current language, by selecting the text you wish to turn into a comment, and then using the Ctrl+K Ctrl+C shortcut, or if you are using Resharper / Intelli-J style shortcuts, then Ctrl+/.

    Server side Comments:

    Razor .cshtml

    Like so:

    @* Comment goes here *@
    

    .aspx
    For those looking for the older .aspx view (and Asp.Net WebForms) server side comment syntax:

    <%-- Comment goes here --%>
    

    Client Side Comments

    HTML Comment

    <!-- Comment goes here -->
    

    Javascript Comment

    // One line Comment goes Here
    /* Multiline comment
       goes here */
    

    As OP mentions, although not displayed on the browser, client side comments will still be generated for the page / script file on the server and downloaded by the page over HTTP, which unless removed (e.g. minification), will waste I/O, and, since the comment can be viewed by the user by viewing the page source or intercepting the traffic with the browser’s Dev Tools or a tool like Fiddler or Wireshark, can also pose a security risk, hence the preference to use server side comments on server generated code (like MVC views or .aspx pages).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can I write, as a comment within a file, the mode that this
in my project an user can write comment [plain text], and view others comment,
I'm trying to write a commenting system, where people can comment on other comments,
I believe there is a method to write a comment in a file that
In msvc i can write #pragma comment(lib, my.lib); which includes my.lib in the linking
I have a code for a comment system. jQuery: function sendComment() { $('#comment_write_area').fadeOut(1); $('#ajax-json-response').fadeOut('fast').html('');
When I write a method and I want to comment it, I write the
How do you guys write comments on some simple code that you use just
How can I read and write comments in a Zip file, using Java? I
As comment to one of the questions here a commenter wrote (emphasis mine): ...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.