Interview with Microsoft MVP Yi Mingzhi: Entering ASP. net mvc 2 Framework Development

Source: Internet
Author: User

BKJIA exclusive interview] BKJIA development channel has been paying attention to the development of ASP. net mvc Framework, and has launched the ASP. net mvc Framework video tutorial for the majority of. NET programmers to learn. Microsoft has released the ASP. net mvc 2 Framework RC version. What changes does the RC version bring to WEB developers? And what improvements will ASP. net mvc 2 be made in the official version in the future? With such a problem, our BKJIA reporter Peng fan specially interviewed Microsoft MVP Yi Mingzhi. ASP. net mvc is a framework for compiling ASP. net web applications in the MVC mode officially provided by Microsoft.

MVP interview characters

Yi Mingzhi, the five-term MVP of Microsoft and chairman of the Yantai. NET club, is currently mainly engaged in Web application development, solutions, architecture design and technical training on the. NET platform.

 

The photo is edited by Yi Mingzhi's instructor BKJIA. note)

1. What new development experience does the MVC Framework give you compared with the previous ASP. NET technology? In what ways can ASP. net mvc framework improve the efficiency of Web development?

Instructor Yi Mingzhi: in fact, ASP. net mvc is also an ASP. NET technology that cannot be stripped from ASP. NET. MVC is a framework technology that divides the implementation of an application into three component roles: model, view, and controller. ASP. net mvc is implemented based on ASP. NET technology, so the basic layer is almost the same.

ASP. net mvc promotes clear separation of concerns and is highly testable, scalable, and pluggable. ASP. net mvc contains powerful URL ing components and HTML Helper classes. You can use very clean URLs and front-end Page code to create WEB applications.

The separation of MVC focus makes collaborative development more harmonious and reduces unnecessary troubles. ASP. net mvc is different from ASP. NET WebForm front-end code (HTML, JS, CSS, etc.) has been greatly improved in terms of control, making us more comfortable when doing Internet applications, especially web2.0 applications. With the support of Visual Studio 2008/2010, we can generate commonly used "CREATE", "modify", "Detailed information", "list" and other pages and the corresponding Controller, this greatly improves the experience and efficiency of developing Web applications, especially Internet Web applications.

2. The first version of ASP. net mvc framework has been released for some time. What do you feel you need to improve during your use? Have these problems been improved in the recently released MVC 2 RC version?

ASP. net mvc 1 has been released for a long time and has been widely used and praised. But as the first version of the MVC Framework, it needs to be improved in many aspects. For example, there is a lack of data verification support for business objects, and application partitions are not supported. For example, backend management is usually stored in the admin directory.

In the ASP. net mvc 2 RC version released at the front end, we were pleasantly surprised to find that the above problems were basically solved accordingly. The new version of MVC has begun to support features such as server and client data verification and Areas.

3. The release of ASP. net mvc 2 RC brings us many new features. Which of the following are your most interesting? We can see that ASP. net mvc 2 supports strong HTML helper methods. What does this improvement mean to developers?

The release of ASP. net mvc 2 RC brings us many new features, including the following:
◆ New strong HTML auxiliary Method
◆ Server and client data verification support
◆ UI auxiliary methods for custom templates
◆ Supports application partitioning (Areas)
◆ Support asynchronous Controller
◆ Use Html. RenderAction to render an Action to the partial part of the page
◆ A large number of new auxiliary methods and APIs
◆ Improved support for Visual Studio

To be honest, I am personally interested in new features, but I am more interested in data verification, Areas, asynchronous Controller, and some new auxiliary methods.
The new strong HTML Helper is a good thing. For example, we can use:

 
 
  1. <%= Html.TextBoxFor(model=>model.Title) %> 

Replace the previous:

 
 
  1. <%= Html.TextBoxFor(“Title”,Model.Title) %> 

In fact, the HTML rendered by these two methods is exactly the same, but the new strong-type auxiliary method allows us to discover view defects during compilation without waiting for the runtime, after all, the runtime check errors may be incomplete. For developers who use ASP. net mvc 2, they should try their best to use strong auxiliary methods to improve application quality.

4. ASP. net mvc 2 can run on VS 2008 and VS 2010. Which version do you recommend? In what aspects can VS 2010 better support ASP. net mvc 2 development?

ASP. net mvc 2 RC currently does not directly support Visual Studio 2010, so it can only be developed normally under VS2008. ASP. net mvc supporting VS2010 should be released soon. You can focus on it. VS2010 provides developers with a large number of new features and functions, such as improved smart prompts (especially smart prompts for JavaScript) and inherent support for. Net 4. These new features of VS2010 will greatly improve the development experience, so for qualified developers, I recommend using VS2010 for ASP. net mvc 2 web development, of course, it will take a few days.

5. data verification is an eternal topic in the ASP. net mvc framework. How do you see the improvements in data verification in ASP. net mvc 2?

ASP. net mvc 2 RC has made a very good enhancement in data verification, you can directly use the System. componentModel. in DataAnnotations, special attributes such as RequiredAttribute and RangeAttribute are used to set verification rules, which is very convenient. In addition, this verification rule is still passed through the server and client, which largely satisfies the basic requirements for data verification. It would be better if the client can directly support the jquery verification library instead of using the Microsoft verification library.

6. You have never understood the T4 support in ASP. net mvc. What are the benefits of such a text template conversion toolbox for WEB developers?

Well, your problem is very good. T4, the Text Templating Transformation Toolkit (Text Template conversion Toolkit), is a highly customized template-based Text generator. ASP. net mvc's enhanced support for Visual Studio includes the use of T4, which is ignored by many developers. Actually, T4 is used in ASP. net mvc is very important, for example, we use Visual Studio for ASP. net mvc development, you need to add a View file to the View directory. On the page for adding a View, you can select to Create a strong View. The "View content" drop-down List contains five default options: Create, Details, Edit, Empty, and List, when you click "Add", Visual Studio automatically generates a View page based on the selected View data class information, which is convenient. The drop-down list of "View content" is actually the name of the predefined T4 template file. The process of generating the View File is actually the execution process of T4, the T4 template files of these views are stored in a special folder under the Visual Studio installation directory. The same is true for Controller file generation.

Why should I ask everyone to pay attention to this issue in ASP. NET MVC 2? As a matter of fact, you can find that the default View template content in MVC2 has changed. For example, when ASP. net mvc 1.0 is used, the template style of each attribute in the default Create view is similar to the following:

 
 
  1.  

  2.          Title: 
  3.        <%= Html.TextBox("Title ") %> 
  4.        <%= Html.ValidationMessage("Title ", "*") %> 
  5.    

     

In ASP. net mvc 2, the style is changed to the following:

 
 
  1.  
  2.     <%= Html.LabelFor(model => model.Title) %> 
  3.  
  4.  
  5.     <%= Html.TextBoxFor(model => model.Title) %> 
  6.     <%= Html.ValidationMessageFor(model => model.Title) %> 
  7.  

The results of the two views are obviously not the same. If your project used ASP. net mvc 1.0, now upgrade to ASP. net mvc 2, the newly added view is different from the original one. If you still run some corresponding js for the original view, then you may get depressed. What should I do? The original view file is generated using the old template in the project.

Of course, when the default View template cannot meet your project requirements, you can also use the T4 template to create a new View template, which is embodied in Visual Studio. I will write a special blog later to share this part with you.

7. How can I better organize applications in the same project by enhancing the Area function in ASP. NET MVC 2?

ASP. net mvc 1.0, if we want to build a background application for our website in a project, and maintain the purity of the URL, it is very difficult, you need to do a lot of work on your own, the effect of implementing the Area function in its own way may not be so good, because by default, the Controller does not differentiate namespaces. For example, the front-end may have the following address: http: // testhost/News/List. The Url of the News management List in the background is: http: // testhost/admin/News/List, which is almost impossible to complete, which makes us very troubled.

  • Hot weekly development: ASP. net mvc 2 released STM Tao
  • Hot weekly development: ASP. NE, Windows 7 Code Competition
  • Detailed description of ASP. net mvc 2 custom Verification
  • ASP. net mvc 2 RC new release enhanced HTML Control
  • Detailed explanation of ASP. net mvc 2's moderate HTML helper Method

ASP. net mvc 2 adds Areas support. To solve the above problem, we can add an Area named "admin". In this case, the project has an Areas folder, which contains the admin folder, admin contains three directories: Controllers, Models, and Views, and AreaRegistration. cs file, and then we are in Global. asa. the routes in the cs file. add a line of AreaRegistration before MapRoute. registerAllAreas ();
That's it. In this way, applications in different regions perform independent organization management in different Area directories, which is quite good.

8. What do you think is the biggest obstacle to enterprise-level WEB development? How to use ASP. net mvc Framework to relieve the pressure on programmers on this obstacle?

51CT O once had a video interview with me, and I talked about some of this content, but some programmers may have misunderstood what I mean due to the title and partial expression. In fact, compared with ASP. net mvc 1.0, ASP. net mvc 2 has made so many improvements. What are the goals of improvement? To a large extent, it is to reduce unnecessary labor volume and potential risks and increase productivity, let developers focus more on business processing. The business I mentioned is not what market Personnel call the business ). Therefore, the biggest obstacle for enterprise-level Web development is that developers waste too much energy on non-business core aspects, for example, data verification, UI code writing, and some tedious but technical aspects.

The new ASP. many new features of net mvc reduce the workload of developers, such as Html. the EditForModel method can directly generate a very good editing interface in the View, and has the ability to automatically identify: bool type attributes, corresponding automatically generate CheckBox, enumeration type automatically generate a drop-down list, and so on. Controller, Action, and Filter all bring us a lot of similar automatic mechanisms, reducing a lot of tedious and tasteless work, so that we can focus more on our core work.

ASP. net mvc extension reading

ASP. net mvc is a framework for compiling ASP. NET Web applications in the MVC mode officially provided by Microsoft.

It comes from Castle's MonoRail. It has already gone through several versions. MVC in ASP. net mvc originally exists in the Desktop program, M is the exponential data model, V is the user interface, and C is the controller. The purpose of using MVC is to separate the implementation code of M and V, so that the same program can use different expressions. For example, you can use a column chart or pie chart to represent a batch of statistical data. The purpose of C is to ensure synchronization between M and V. Once M changes, V should be updated synchronously.

MVC pattern Diagram

The ASP. net mvc framework is another development method after ASP. NET WebForms. It provides a series of excellent features that enable ASP. NET developers to have another choice. ASP. net mvc Framework Options are very clean and easy to use. It will allow you to easily keep focus on separation in applications and help with clean testing and TDD. Understanding

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.