MVC2 research topic (I) -- use MVC to organize and manage Serviceboy for your family income Reprinting

Source: Internet
Author: User

Hi everyone, I'm Serviceboy. I haven't written a blog for a long time because of my work. In the present era, it can be described as "information explosion", except for the traditional "Mouse + cement" ASP. in addition to the NET programming design, Microsoft also launched a new generation of website development framework-MVC. The function of this MVC framework is similar to the Stucts1 version in Java. However, it is much easier to get started than Stucts1. The current MVC version has reached 2 (Beta 2) to help you better learn and understand the MVC2 mechanism and some common skills. I will first show you the charm of MVC through a simple and practical program "Household Income and Expenditure Management System.

First, you can click here to download this document and publish it to your IIS7 (later this tutorial will introduce some usage of the new IIS7 in Win7 ).

In addition, you can click here and download the free and open-source MVC Beta2 (VS2008 with SP1 version, because this will help you create MVC templates, as well as necessary components such as LINQ-TO-SQL programs in the author program ).

 

I. project introduction:

This project allows users to browse all or specify a date range, perform fuzzy search on income and expenditure items, edit, view, and delete some of the content, and insert new income and expenditure items and income and expenditure category names. Its organizational structure is built on Microsoft's MVC (Beta 2) and includes the following:

V FinanceManagerController: Located in the Controllers folder, acts as a global controller that separates logical services and performs redirection. Including:

Function Name

Function

Index

This function is used to automatically filter data based on input parameters and return code by page.

AddItem

Used to jump to the page added by the Income and Expenditure Project.

AddType

Used to jump to the page for Adding revenue and expenditure categories.

SaveInfo

Save the income and expenditure items.

SaveType

Save the income and expenditure category.

Read

Used to browse a specific record and jump to the browsing page.

Edit

Used to edit a selected record and jump to the editing page.

Update

Used to update the edited records, write the records to the database, and retrieve the Index on the main interface.

Delete

Deletes a known record and calls back the Index on the main interface.

The v View folder contains a FinanceManager folder, which contains the following content: "SaveInfo", "SaveType", "Update", and "Delete, the aspx file that is exactly the same as other functions of FinanceManagerController.

V DAL Folder: contains two Functions: "Functions" (stores common Functions for calling on other function pages, such as "GetAllItems" in this example to obtain all income and expenditure category options) and "Paging" (store all information on the page ). Of course, operations related to database addition, deletion, modification, and query should also be included in the example. However, the author automatically encapsulates Modal and DAL because of the use of Linq, therefore, even if it is in Modal.

V Shared folder: contains a My97DatePicker free calendar (date selection) control and a css file for page decoration and pure page beautification.

V APP_DATA: contains a script file for automatically creating databases and tables, and a large amount of test data. Readers can use this file to automatically generate databases and tables to run your program and experience the pleasure of MVC.

V Scripts: a third-party javascript tool integrated by Microsoft, such as JQuery, which has not yet been involved in this project.

 

Ii. Use IIS7.0 and how to run the MVC program on IIS:

"Easier to publish and easier to get started with" is my first feeling of using IIS7.0 and then releasing this program for my family. IIS7.0 has completely refined many features in the previous IIS, and uses the group form to "classify by category. To publish an MVC program, follow these steps:

V is used to install IIS7.0. In Win7, you no longer need to install any sources. You can go to the control panel (switch to a large icon) "-->" programs and functions "-->" enable or disable Windows ", select the following content:

1) Internet Information Service: Web management tools --> except for "IIS6 management compatibility", you can check other options.

2) in the World Wide Web Service:

2.1) Security --> select "Basic Authentication" and "request filtering ".

2.2) Common Http functions --> "static document" and "Default document" are required to set the start page and apply CSS styles.

2.3) the application development function --> ASP. NET option is required, and other options are selected.

V. configure access permissions for IIS: select the decompressed project package, right-click Properties, then, choose "security"> "edit"> "add"> "advanced"> "Search now" and select "computer name \ IIS_IUSRS" to confirm and save the settings.

V. Finally, add the decompressed project to IIS, and choose control panel, Administrative Tools, Internet Information Service (IIS) manager, and website (stop the default website first, click the "stop" button on the right, right-click "add Website", start your favorite name, and select your physical path (the name of the decompressed package ), write non-80 ports (such as 80, 6060, etc ......).

 

Iii. Notes for publishing MVC to IIS7.0:

The author may be clumsy, and the release was successful after a day. Currently, the following two major problems are encountered:

1) The sa method must be used for database connection; otherwise, "XXXX Login Failed" may occur.

2) Css of templates and application templates: I and most readers may have a feeling that, that is to say, it is sometimes not that easy to apply CSS files to templates and application templates at the same time? Why? If the template and the application template file are not in the same location, the relative path of the CSS file referenced by the template must be different from the relative path of the referenced CSS file of the Application Template File, therefore, the path of the application template cannot be applied to CSS ("view source code" clearly tells us that the file of the Application Template is parsed into HTML, the referenced path CSS is the path that references CSS in the template !).

Currently, there are two solutions:

V extracts most Shared files and puts them in a folder (for example, Shared files provided in the case). Then, the files are placed in the root directory, and the paths referenced by the template are absolute paths.

V, of course, you can put the template, the page that applies the template, and CSS in the same space, so that you can reference it relatively, but it is not recommended because it is too messy.

Now, you can take a good look at the simple and practical application of the author, and provide a clear explanation of the Source Direction of your household income and expenditure. However, this is just the work of The author. Later I will introduce in detail the principles of MVC and some tips worth noting through the development of this program. Please watch it. Thank you!

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.