ASP. net mvc Case Study (1) (1)

Source: Internet
Author: User

Preface

ASP. net mvc, as Microsoft's official MVC solution, has been launched for some time. It can be said that since its launch, it has been widely used. After a long Preview, we finally launched its beta version a few days ago. In addition, in the official documents, Microsoft declared that the final official version would not change much compared with the beta version. Therefore, it is time for developers on the. NET platform to learn ASP. net mvc.

This series of articles, as an introductory tutorial on ASP. net mvc, will not introduce the concepts and theories. Instead, we use case studies to learn ASP. net mvc. In this series of articles, I will gradually complete an "announcement publishing system ". My writing strategy is to do it first, instead of explaining the concepts and theories first.

In addition, I have several points to note:

1. In order to fully focus on ASP. net mvc, the business processing of this Demo will use Mock. That is, it does not actually access the database, but virtual data.

2. This Demo will not consider any art issues.

Next, let's get started with ASP. net mvc. In this article, we will finish all the preparations.

Configure the environment

If ASP. net mvc has not been installed, download and install it here.

After the download, follow the prompts to install it.

Create a project

After installing ASP. net mvc, create a project in VS, you can see that there is an "ASP. net mvc Web Application option, select it, create a new project, and name it "MVCDemo ".

After the project is created, you can see that many folders have been created by default. Here we will briefly describe the role of each folder.

Content-stores some resource files, fragments, and CSS required by the application.

Controllers -- stores the Controller class.

Models -- stores business model components.

Scripts -- stores JavaScript script files.

Views -- stores Views.

It doesn't matter if you don't know some concepts. I will explain them later.

Preparations

After creating a project, we need to create a Mock business model. In this way, we will directly use these "spoofing" business models for business processing, focus on ASP. net mvc learning.

First, create three folders under Models, namely Entities, Interfaces, and MockModels, to store entity classes, Interfaces, and Mock business Models respectively.

Entities have two categories: CategoryInfo and AnnounceInfo, which are the announcement category and the announcement entity class respectively. The Code is as follows:

CategoryInfo. cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
Namespace MVCDemo. Models. Entities
{
/// <Summary>
/// Category object class
/// </Summary>
Public class CategoryInfo
{
Public int ID {get; set ;}
Public string Name {get; set ;}
}
}

AnnounceInfo. cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
Namespace MVCDemo. Models. Entities
{
/// <Summary>
/// Announcement entity class
/// </Summary>
Public class AnnounceInfo
{
Public int ID {get; set ;}
Public string Title {get; set ;}
Public string Content {get; set ;}
}
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.