- Use CDN
- Use both Client-side validation and server-side validation
- Use bundling to avoid repetitive call in each view
- Use minification for faster load
- Check Javascript enabled for the browser or not before loading the page.
- Use Partial views for developing reusable components
- Use the Razor View engine as it is very light and user-friendly
- Use validation summary to show all the errors in on go instead of showing each error separately.
- Remove all .pdb files while deploying the code.
- Use Release mode instead of Debug mode while deploying the code. It will automatically remove the .pdb files.
- Use Browser developer tool and fiddler or Postman like tools to debug the UI/View code.
- Use Glimpse like tools available in Nuget to debug the Server side code.
- Use strongly typed view
- Remove unused references from your code
- Use Areas to simplify your code modules
- Keep all business logic in models instead of View. Views should only respond to render the HTML page to the browser
- 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.
- Use _Layout view for a consistent look and fell through the application.
- Keep DisplayTemplates and Editor Templates code in Shared folder for reusability.
- Use centralized error handling logic.
- Remove/close unused connection which is open by using " Using" Statement.
- Use TempData for short-lived instances and use viewBag and ViewData for long-lived and large data.
Sunday, 23 December 2018
Best practices for MVC application
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment