Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of .NET MVC

Shulou Source: shulou.com Published: 2022-06-03 12:53:26 09月18日 Update

This article mainly introduces the example analysis of .NET MVC, which is very detailed and has certain reference value. Friends who are interested must finish it!

I have heard the name of MVC for a long time, but I have never studied it. In the past, I used .NET WebForm most often, and I was more accustomed to the three-tier architecture. Recently, the company will use the MVC framework to do some projects, so I also began to contact and learn. Read some tutorials, generally understand the general meaning of M-V-C, a general understanding of the framework, but have to admit that there are some specific details and WebFrm are different, here is just a simple example to let it run. After looking at some examples, most of them use LinqToSql, and here they use ADO. It feels easier this way, hehe.

Since I have done the PHP program before, it is easy to understand the way the foreground page is displayed. It's just that in the MVC framework, there are some default routing rules (which can be customized, of course). This rule is quite special.

All right, let's give an example directly!

First, create an empty MVC project, as shown in the figure, here is MVC version 2.0

This is named "FirstMvc", and the directory structure of the project is automatically added.

Create a new controller under the "Controller" directory, named "MemberController.cs"

At the same time, add the corresponding view under the "View" directory, and here add an Index

The operation of the data logic is basically done in the controller, which is implemented in MemberController.cs.

To be more realistic, we also build an entity class under the Model directory, named Member.cs

All right, when the preparatory work is done, let's get started.

Front desk-View

Table {width: 50% bordermurtop: 1px solid # e5eff8bordermurright: 1em auto;border-collapse: collapse;} td {color: # 678197borderthumb bottom: 1px solid # e5eff8borderthumb left: 1px solid # e5eff8transferpadding: .3em 1emextextalignment: center;} above is all the content of the article "sample Analysis of .NET MVC". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Catalog just instance or project example analysis content foreground controller architecture framework article rules control value interest at the same time place name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB Xiaomi Docker macOS