59

I want to add Copyright @ 'current_year' to the footer (in cshtml file) of my page. I often made it using javascript but since I am using ASP.NET MVC 3 I would like to do this using ASP.

I was trying construction like:

@response.write("Current Year: "&Year(Date))

But it didn't work in MVC 3 and I can't find solution that is working.

2 Answers 2

138

Try the following:

Copyright @@ @DateTime.Now.Year
2
  • 12
    Shouldn't the @ be ©? As in, the Copyright symbol "©"?
    – Brian Lacy
    Jan 30, 2014 at 21:05
  • 3
    You can just add '©', depends if your document is UTF-8. Jun 17, 2014 at 23:34
3

In a .razor page in an ASP.NET Core application, e.g. within the <div> </div> of your footer, the following works too:

Copyright &#169 @DateTime.Now.Year

Added the copyright sign too and the double @@ is not needed in a razor page; it gives an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.