. NET is a set of frameworks for HTML, JS, CSS, and server-side scripting to build Web pages and websites.
There are three development modes: Web pages (single-page model), MVC (Model View Controller), Web Forms (event-driven model)
Introduction to Web Forms
1. The simplest model of ASP.
2, similar to PHP and ASP
3. Built-in templates and helpers for databases, videos, social media, and more.
MVC
MVC divides a Web application into three different components:
1, the model for the data
2. View for Reality
3, for the input controller
Web Forms
1. The traditional ASP. NET event-driven development model.
2. Added Web pages for server controls, server events, and server code.
==========================================
- Web Pages (using Razor syntax)
- MVC (Model View Controller)
- Web Forms (Legacy ASP. NET)
What is Razor?
- Razor is a markup syntax for adding server-based code to a Web page
- Razor has the capability of traditional ASP., but is easier to learn and easier to use
- Razor is a server-side markup syntax similar to ASP and PHP
- Razor support for C # and Visual Basic programming languages
C # 's main Razor syntax rules
- Razor code block surrounded by @{...}
- In-line expressions (variables and functions) start at @
- The code statement ends with a semicolon
- Variables are declared by var keyword
- Strings are surrounded by references.
- C # code is case sensitive
- C # files have the. cshtml extension.
============================================
Example code:
<! DOCTYPE html>The whole work of the Ps:razor code is to detect the current time on the server and then display it.
================================================================
<!--single-line code block-->@{var mymessage = "Hello World";} <!--multiple lines of code block-->@{var greeting = "Welcome to our site!"; var WeekDay = Datetime.now.dayofweek;var GreetingMessage = greeting + "Today is:" + WeekDay;} <p>the greeting is: @greetingMessage </p>
Web pages (single-page model)