11. Hi, how are you? I'm Sern Hao from SernHao Tv, the topic I want to share with you is "About Controller in ASP.Net Core".
Here, I will explain in simple terms for you to explain a few on the ASP.Net Core about Controller in a few key points:
1) What is the Controller?
- is an interactive Class in the MVC.
- In MVC, View is used to display information. Model is used to link the database. The Controller is responsible for receiving and
transferring data between View and Model.
- Connect Model (or data) and View.
2) Controller's basic usage. (Demo)
- Controller handles Http-Post (route data) and Http-Get (query-string)
- Receives the user input from View and then responds with a specific response.
- Execute business rule and functions.
3) How to create a Controller in ASP.Net Core. (Demo)
- In the video, I will explain how the Controller was created, as well as some of the main functions.
- roughtly explain the life cycle of controller in the ASP.net Core.
- default template: "{controller=Home}/{action=Index}/{id?}") [“/[Controller]/[ActionName]/[Parameters]”]
- In Solution Explorer, right-click folder of “Controllers” > “Add” > “New Item...“ > select ”MVC Controller Class“
- “Index” is the default method that will be called on a “Controller”
Bonus:
1) ASP.Net Core is a. Net Framework, which uses .Net Framework 4.6. ASP.Net Core can also be regarded as C # and MVC 1-6 series is a
big step forward. Moveover, visual studio 2015 will use as development tool for create ASP.Net Core program.
2) In Visual Studio 2015, you can re-run your app by refresh the browser after changing and save the code without debuggin (Ctrl + F5)
again.
12. Reference 参考:
1. Visual Studio Code Tutorial for Beginners - CodeGeek
https://www.youtube.com/watch?v=5WyJibE3ZK0
2. What is MVC? Model View Controller - HandsonERP
https://www.youtube.com/watch?v=qXRcVhWxuaU
3. Introduction to ASP.NET MVC Part 1/3: What is MVC and why should you use it? - Roger Harford
https://www.youtube.com/watch?v=YSHW9F2dtOY
4. Adding a controller - By Rick Anderson
https://docs.asp.net/en/latest/tutorials/first-mvc-app/adding-controller.html