Monday, July 04, 2011

ASP.Net MVC Best Practices

ASP.Net MVC Best Practices
1. Create Extension Methods of UrlHelper to generate your url from Route.
2. Create Extension Method of UrlHelper to map your Javascript,Stylesheet and Image Folder
3. Abstract DI Container
4.Keep your controller free from HttpContext and its tail
5.Use UpdateModel Carefully
6. Avoid ViewData,user ViewData.Model(Say No to "Magic strings"
7. User PRG Pattern for Data Modification
8. Action Filters
Use ActionFitlers for "shared " data. Use Action filters to retrieve data that is shared among different views. Use Partial view to display them.
9. Write your own HTML . If there ia n if , write an HtmlHelper.
10 . Do not put javascript in you code
11. User JQuery and JQuery UI
12. Create new ActionResult if you need one.
13.


References:
1. http://weblogs.asp.net/rashid/archive/2009/04/01/asp-net-mvc-best-practices-part-1.aspx
2. http://stackoverflow.com/questions/709429/asp-net-mvc-best-practices-tips-and-tricks

No comments: