Log in

Previous Entry | Next Entry

QuestPond’s Best Practices in ASP.NET MVC

What are best practices that need to be followed in ASP.NET MVC?

Whether it is ASP.NET MVC, WCF or ASP.NET Web Forms when it comes to best practices its endless.

Let me share couple of practices I followed during ASP.NET MVC development.

    1. Keep Model as separate class library.

    2. Implement Repository pattern to isolate Business layer from Data Access Layer.

    3. Follow MVC architecture properly
                  a. Controller should contain only user interaction logic
                  b. View should contain only UI Design

    4. Use ViewModel and isolate View from presentation and Data Transformation logic.

    5. Always have base controller created. Means make sure your controllers are not directly inheriting from
         Controller class instead there should be an intermediate base controller
         public class BaseController: Controller{….}
         public class CustomerController:BaseController{}

    6. For Generating input controls in view always use Html helper class methods.

   7. Always put appropriate Http verbs on action methods. Example: If it is a post action
        HttpPost and if it is Get put HttpGet action. By default it will be both and it should not be.

   8. Strictly follow the traditional best practice, avoid magic strings. Magic strings means
        writing something in Double quotes.

   9. If there is an action method which returning same result many times, apply caching into it.

10. Action methods with HttpGet attribute attached should not be performing an operation.
       Example: it should not delete, update any record. In short Get methods should perform
       anything which looks like Post.

11. Avoid putting hardcoded Action URIS.
       Example :
       Instead of

12. Always include bundling and Minification in your application.

13. All your view should be strongly typed

14. Use Model Binder for updating Model class object with posted data instead of manual update.

So the story of best practices doesn’t ends here we have more complete detailed article on best practices in .NET

For technical trainings on various topics like WCF (Windows Communication Foundation), MVC (Model View Controller), Business Intelligence, Design Patterns, WPF, TFS and Basic fundamentals feel free to contact SukeshMarla@Gmail.com or visit www.sukesh-marla.com

For more stuff like this, click here. Subscribe to article updates or follow at twitter @SukeshMarla
Copy right www.questpond.com


Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

March 2017


Powered by LiveJournal.com