ASP. net mvc best practices 27 +

Source: Internet
Author: User

12 ASP. net mvc Best Practices

M

Domainmodel! = Viewmodel

Use actionfilters for "shared" Data

V

Do never user code-behind

Write HTML each time you can

If there is an IF, write an htmlhelper

Choose your view engine carefully

C

Delete the accountcontroller

Isolate controllers from the outside world

Use an IOC container

Say no to "magic strings"

Build your own "personal conventions"

Pay attention to the verbs

 

ASP. net mvc Best Practices

Use

Use jquery and jquery UI

Use bootstrapper in global. asax

Use action filter to convert to compatible action Methods Parameters

Use updatemodel carefully

Use PRG pattern for data modification

Do not

Do not make any hard dependency on the Di container, use common service locator

Do not put your JavaScript codes in your view

Avoid viewdata, use viewdata. Model

Do not make any hard dependency on the Di container, use common service locator

Controller will not contain any domain Logic

Decorate

Decorate your most frequent action methods with outputcache attribute

Decorate your action methods with proper acceptverbs attribute

Decorate your most frequent action methods with outputcache attribute

Decorate your action methods with proper acceptverbs attribute

Create

Create new actionresult if required

Create extension methods of urlhelper to generate Your URL from route

Create layer super type for your viewmodel and use action filter to populate common parts.

Create Extension Method of urlhelper to map your JavaScript, stylesheet and image folder

Htmlhelper Extension

Split your view into multiple viewusercontrol

Tips

Routing consideration

Encode

Action filter location

Keep your controller free from httpcontext and its tail

Original article address:

Http://weblogs.asp.net/rashid/archive/2009/04/01/asp-net-mvc-best-practices-part-1.aspx
Http://codeclimber.net.nz/archive/2009/10/27/12-asp.net-mvc-best-practices.aspx

 

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.