Building a Simple Blog Engine with ASP. net mvc and LINQ-Part 1

Source: Internet
Author: User
Tags what is asp

Summary

Microsoft released the first CTP version of ASP. NET 3.5 Extensions, which contains an important extensions of ASP. NET 3.5: ASP. net mvc Framework. ASP is used in this series of articles. net mvc and LINQ build a simple Blog system. In the first part, Keyvan introduces the MVC mode and ASP. net mvc Framework and basic principles of the simple Blog system.
Original article address: Building a Simple Blog Engine with ASP. net mvc and LINQ-Part 1

Content

  • Introduction
  • What is MVC?
  • What is ASP. net mvc Framework?
  • KBlog Basics
  • Create a project
  • Start
  • Further reading
  • Summary

Introduction

A few weeks ago, the first CTP version of ASP. NET 3.5 Extensions was released, which contains the first public version of ASP. net mvc Framework. There are already many tutorials, blog posts, and Web Cast on the network. They are excellent resources for learning this MVC Framework.

I plan to write several articles about ASP. NET MVC Framework and use MVC and LINQ to build a simple Blog system. I will show you the details of all the steps and discuss some in-depth topics. I have not completed the system yet. I will write the code while writing the article.

This simple application is included in ASP. net mvc Toolkit, but it is not described in detail yet. Why do I need to write this series when I have a similar tutorial? In my opinion, learning the MVC Framework curve must follow several steps to build a simple Bolg system and describe the process. It will be a good example of learning ASP. net mvc Framework.

This is the first article in this series (I will finish this series in a few weeks). It mainly introduces some basic information.

What is MVC?

Yes. What is MVC? Others have better elaborated on this concept, but I want to repeat it in my own language.

MVC is a methodology that builds applications based on the idea of dividing implementation into Model, View, and Controller roles.

Let's take a look at the above sentence. We think that MVC is a method rather than a non-technical method, so many applications have been created before Microsoft applied it to ASP. NET. I stress this because I have seen some guys think that MVC is a technology designed specifically for ASP. NET.

I still need to briefly introduce these three roles:

  • Model: The role that maintains the status. It is usually a class that describes the data in the database.
  • View: role that presents data to the end user through the user interface. It may be a set of user interface elements, such as text boxes, editors, or buttons.
  • Controller: the role that receives and processes user input. In fact, the Controller implements the current logic to process user requests.

To design applications that depend on data interaction, using MVC is a good method. The biggest advantage of MVC is that it can easily implement unit testing. Using Controller, you can easily perform unit tests on MVC applications and implement test-driven processes (Red-Green-Refactor ).

Figure 1 shows the structure of the MVC mode. The Model is independent of the Controller and View, which makes Model testing easier. On the other hand, the separation of Model, View, and Controller allows developers to easily test MVC applications. In fact, it is very important to separate views from controllers and models as user interface elements, which simplifies the testing process.

Figure 1 MVC Structure

 


I will not discuss MVC too much. You can refer to Scott Guthrie's post and Wikipedia, which is enough for you to get started.

What is ASP. net mvc Framework?

ASP. net mvc Framework is Microsoft's application of MVC in ASP. NET. in ASP. NET 3.5, it provides the necessary features for creating MVC-based Web applications.

ASP. net mvc Framework is still being built. As part of ASP. NET 3.5 Extensions CTP, only one public version is available for download.

After downloading and installing this component, you can feel the advantages of ASP. NET Extensions. It also automatically installs some project templates on Visual Studio 2008.

Along with this download component, there is also an MVC toolkit package, which provides some useful tools for MVC development. I will also use them in this series of articles.

KBlog Basics

In this series of articles, I will create a simple Bolg tool called KBlog.

The Bolg system supports Blog publishing, comments, and classification. A Blog can only have one type, but can have any number of comments. The system only targets a single user and contains URL modes to process public and private pages. All of these include their own IDs. For simplicity, KBlog does not support using name as part of a URL.

As the first step, I will use SQL Express as the database. I manually enter some data. After the public page is discussed, I will introduce the management page. You can enter data on the Management page.

Create a project

Obviously, the first step is to create a project in Visual Studio. If ASP. NET 3.5 Extensions CTP is successfully installed, you can see the "ASP. net mvc Web Application" project under the Web category. I name the system KBlog (figure 2 ).

Figure 2 create an ASP. net mvc Web Application Project

 


Visual Studio then generates a project based on the predefined template and structure.

Start

Visual Studio generates a simple ASP. NET Web Application project.

Figure 3 ASP. NET MVCSolution Structure

 


This project contains references. The most important one is System. Web. Extensions accessories. There are also four folders: Content, Controllers, Models, and Views.

  • The Content folder only saves one default CSS style file.
  • The Controllers folder saves the Controller class.
  • Save the Model class in the Models folder.
  • View stores View files and contains folders containing aspx and master files.

As you can see, Controllers, Models, and Views are more important to us because they are used to save Controller, Model, and View. Such a name is not fixed. You can replace it with your own structure.

In addition, there are some well-known ASP. NET folders. Their additional definitions will be introduced later.

One thing to note is that the file Default. aspx, as described in its content, cannot be deleted to enable MVC for the application when the IIS user accesses this page.

This article describes how to use it. Gradually, I will add some implementations for the project in the following article.

Further reading

The following lists some excellent Blog resources. You can read this article to learn more about ASP. net mvc Framework. They already contain excellent information about ASP. net mvc. This technology is applicable to ASP. NET is brand new, so there are not many resources currently, but fortunately, MVC has become very popular in development. In just a few weeks, we have seen a strong response in the industry.

  • Scott Guthrie
  • Scott Hanselman
  • Phil Haack
  • Rob Conery
  • Brad Abrams

Summary

In this ASP. in the first article of the net mvc Framework series, I want to introduce the MVC pattern, the basic principles of MVC, ASP. net mvc Framework and basic information of the simple Blog system that will be compiled in this series of articles. I also keep the structure of the MVC solution in ASP. NET MVC.

In the following sections, I will gradually establish this Blog system and introduce the principles and technologies related to ASP. NET MVC Framework.

 

Related Article

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.