Monday, December 13, 2010

Few basic things to follow in Asp.Net MVC

After reading and writing code on Asp.Net MVC, I feel there are soo many ways we can improve our approach but few important best practices that we must follows are listed below.
  1. Security considerations
  2. Dependency Injection pattern
  3. Controllers must not interact with HttpContext, Data access classes, Configuration etc and never contain any logic
  4. Adopt PRG Pattern
  5. Verbs are important
  6. Create Extension methods of UrlHelper
  7. Avoid ViewData use ViewData.Model
  8. Html Helper extensions
  9. Always Encode
  10. Routing

Thursday, March 25, 2010

File upload working within Update Panel

If we add File upload control with in an update panel and then we use that file upload control in code behind it didnt get the file contain in it. so for that we have to set a postback trigger for full page postback and then access file upload control.

Thursday, January 14, 2010

Implement Sql Transaction in

SqlTransaction trans = null;
string conn = @"Data Source=.\SQLEXPRESS;Initial Catalog=ABC;Integrated Security=True";
using (SqlConnection connection = new SqlConnection(conn))
trans = connection.BeginTransaction();
SqlCommand cmd = new SqlCommand("Command Text",connection, trans);
catch (Exception ex)