Sunday, 23 December 2018

Best practices for MVC application

  1. Use CDN
  2. Use both Client-side validation and server-side validation
  3. Use bundling to avoid repetitive call in each view
  4. Use minification for faster load
  5. Check Javascript enabled for the browser or not before loading the page.
  6. Use Partial views for developing reusable components
  7. Use the Razor View engine as it is very light and user-friendly
  8. Use validation summary to show all the errors in on go instead of showing each error separately.
  9. Remove all .pdb files while deploying the code.
  10. Use Release mode instead of Debug mode while deploying the code. It will automatically remove the .pdb files.
  11. Use Browser developer tool and fiddler or Postman like tools to debug the UI/View code.
  12. Use Glimpse like tools available in Nuget to debug the Server side code.
  13. Use strongly typed view
  14. Remove unused references from your code
  15. Use Areas to simplify your code modules
  16. Keep all business logic in models instead of View. Views should only respond to render the HTML page to the browser
  17. Do not mix up the unnecessary code in Controllers. It should only respond to render the different controllers and controller action method to render the appropriate view to the browser.
  18. Use _Layout view for a consistent look and fell through the application.
  19. Keep DisplayTemplates and Editor Templates code in Shared folder for reusability.
  20. Use centralized error handling logic.
  21. Remove/close unused connection which is open by using " Using" Statement.
  22. Use TempData for short-lived instances and use viewBag and ViewData for long-lived and large data.

No comments:

Post a Comment