Customizing code templates for ASP.net mvc

Source: Internet
Author: User

Right-click the Controller folder in the ASP.net MVC type project, select Add=>controller ... , some default code is inserted into the new controller.

Right-click ADD View in Controller's action methods, and insert some code into the new view. The code you insert when you create a new view differs depending on the context and your choice, and seems to have a large code generation capability.

Both of these generate the code using Visual Studio's T4 code generation template, the T4 template and the Codesmith template are the same principle. The T4 template generation code feature has long been in VS, but rarely known, a hidden feature of vs. The templates used for both of these features are in C:/Program files/microsoft Visual Studio 9.0/common7/ide/itemtemplates/csharp/web/mvc/codetemplates Table of Contents.

Copy the entire directory of the Codetemplates and put it under the project.

We can modify the template here, or we can add our own template, you can choose which template to add code. This implements the code template for custom asp.net mvc.

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.