4 Best Practices for ASP.NET MVC Application

Published on March 8, 2013 by Senthil Kumar

Filed under ASP.NET

Last modified March 8, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 11035 times

There are plenty of best practices for ASP.NET MVC Application which can be followed by the ASP.NET MVC Project developer.

In this blog post , we will cover 4 of the best practices when developing ASP.NET Web Applications.

4 Best Practices for ASP.NET MVC Application

1. Request Validation

The Request Validation is one of the features in ASP.NET MVC which is enabled by default and prevents the potential dangerous content to be submitted.

If you need to send the HTML markup tags in your controller , you might want to disable the Request Validation feature with the [ValidateInput(false)] attribute on top of the Action method.

2. Strongly Typed Models

ViewBag , ViewData and tempData are definitely useful in ASP.NET MVC but the strongly typed models should be preferred when binding to UI which has its own advantages.

3. Caching Data

The Application’s performance can be improved with the caching mechanism to en extent. To enable the caching for the model , just add the attribute [OutputCache(Duration=3600)] to the action.

4. Data Annotations and Validations

Validations are important aspect of the ASP.NET Web Application . The validation will enable the user to allows only the data being entered in the UI. The developers can utilize the DataAnnotations class and apply attributes on each properties of the model in order to apply validations.

1 Comment

  1. Interesting .NET Links – March 9 , 2013 | TechBlog
    March 9, 2013 - 7:47 pm

Leave a Comment


You might be Interested in these Posts

How to read connection string from web.config in ASP.NET and C# ?

Here's a sample code snippet demonstrating how to get the connection string from your ASP.NET web.co...

How to return Json instead of XML in ASP.NET Web API ?

When you make a call to the ASP.NET Web API action method and notice this in Google Chrome browser ,...

How to Add Web API to existing ASP.NET Web Forms Project ?

In one of the previous posts , we saw how to add the WebAPI to the existing ASP.NET MVC project. Wel...