Rewillis Posted February 1, 2021 Share Posted February 1, 2021 Attention: w3schools.com staff: I have copied the following code directly from the w3schools.com web site, regarding an ASP example: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Web Pages Demo</title> </head> <body> <h1>Hello Web Pages</h1> <p>The time is @DateTime.Now</p> </body> </html> However, when I serve it up to my IIS 10 web server, the current date and time is not sent to my web browser. Instead, I get the following output: "Hello Web Pages" "The time is @DateTime.Now" I have saved my web page with the ".htm," ".aspx," and ".asp" file types, but I get the same result as described above. Why is the current date and time not being sent to my web browser? Link to comment Share on other sites More sharing options...
dsonesuk Posted February 1, 2021 Share Posted February 1, 2021 Because that is text, you are getting exactly what you entered, you have to separate text from asp usually using <%= %> Link to comment Share on other sites More sharing options...
Rewillis Posted February 1, 2021 Author Share Posted February 1, 2021 dsonesuk, I need more details. When I use <%@DateTime.Now%>, and serve up my web page, I receive an HTML 500 error message. Suggestions? Link to comment Share on other sites More sharing options...
Rewillis Posted February 1, 2021 Author Share Posted February 1, 2021 dsonesuk, please disregard my previous message. I will figure it out. Link to comment Share on other sites More sharing options...
Funce Posted February 1, 2021 Share Posted February 1, 2021 Hi @Rewillis You've missed out one character! Make sure you have the = character after the first % sign so that the @DateTime.Now is outputted rather than only being evaluated. <p>The time is <%= @DateTime.Now %></p> Link to comment Share on other sites More sharing options...
dsonesuk Posted February 2, 2021 Share Posted February 2, 2021 Yeah! I just added '=' as a decoration, it has no real purpose....oh wait! Yes! It does. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now