Imran Baloch's Blog

  • Race Condition in AsyncController

         Introduction:

              ASP.NET MVC 2 provides AsyncController which enables you to define controller actions that run asynchronously. AsyncController become very useful in IO bound tasks, for example calling a remote web service or query large amounts of data from a slow database, etc. In these situation you will not tie up a request processing thread(ASP.NET thread), instead you use AsyncController which enables you to use non-ASP.NET thread to execute long IO bound operations. AsyncController will increase overall application performance if your application is using long running IO bound task. Synchronization is very important if you are performing multiple task in AsyncController, but if you don't care then your application may come into a situation that we refer to as a race condition. Race condition occurs when several threads attempt to access the same data and do not take account of what the other threads are doing which result in corrupt data structures. So in this article I will show you how your application may come into race condition situation and how you can avoid race condition situation.

  • ASP.NET MVC Client Side Validation With Ajax.BeginForm

         Introduction:

              The ASP.NET MVC Ajax.BeginForm HTML helper make it very easy to submit form asynchronously and allows to perform partial page updates. That's why lot of developers likes to use Ajax.BeginForm HTML helper. In my last blog post I talked about how you can implement client-side validation for dynamic contents at here. I showed you that how you can leverage jQuery to make it possible. This will work very well if you want to use only jQuery. But what if you want to use Ajax.BeginForm Helper? So in this article I will show you how you can implement client-side validation for dynamic contents using Ajax.BeginForm.

  • ASP.NET MVC Client Side Validation With Dynamic Contents

        Introduction:

              There are lot of occasions when developers do not let the users to fill the complete form at once, instead developers use wizards steps to get the different information from users at different steps. For example, ASP.NET(Web Form) Wizard Control which allows the developers to easily create multi step user interface. But unlike traditional post back for every step, developers likes to use Ajax to show different wizards steps without a complete post back. Every wizard step includes different client side validation rules. In this article I will show you how to do the same task in ASP.NET MVC using the built-in client side validation libraries.

  • Persisting Session Between Different Browser Instances

     
       Introduction:

              By default inproc session's identifier cookie is saved in browser memory. This cookie is known as non persistent cookie identifier. This simply means that if the user closes his browser then the cookie is immediately removed. On the other hand cookies which stored on the user’s hard drive and can be reused for later visits are called persistent cookies. Persistent cookies are less used than nonpersistent cookies because of security. Simply because nonpersistent cookies makes session hijacking attacks more difficult and more limited. If you are using shared computer then there are lot of chances that your persistent session will be used by other shared members. However this is not always the case, lot of users desired that their session will remain persisted even they open two instances of same browser or when they close and open a new browser. So in this article i will provide a very simple way to persist your session even the browser is closed.



       Description:

              Let's create a simple ASP.NET Web Application. In this article i will use Web Form but it also works in MVC. Open Default.aspx.cs and add the following code in Page_Load.