In this chapter you will learn how to add Razor code to a web page
Adding Razor Code
Remember the web page from previous chapter:| <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Hello World Page</title> </head> <body> <h1>Hello World Page</h1> <p>Hello World Page</p> </body> </html> |
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Hello World Page</title> </head> <body> <h1>Hello World Page</h1> <p>Hello World Page</p> <p>The time is @DateTime.Now</p> </body> </html> |
The Razor code does all the work of determining the current time on the server and display it. (You can specify formatting options; this is just the default.)
Run the page. You now see the current date and time on the page:
No comments:
Post a Comment