Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Contents tagged with C#

  • AsyncController v/s SessionLess Controller

        Introduction:

              AsyncController is introduced in ASP.NET MVC 2 while SessionLess controller is introduced in ASP.NET MVC 3. AsyncController allows you to perform long running I/O operation(s) without making your thread idle(i.e., waiting for I/O operations to complete). On the other hand, SessionLess controller allows you to execute multiple requests simultaneously for single user, which otherwise execute multiple requests sequentially due to session synchronization. Understanding these concepts may be easy for you but I have seen a lot of guys become confused on these concepts. In this article, I will show you how to use AsyncController and SessionLess controller in ASP.NET MVC application. I will also compare them and tell you what to use when, where, and the why.

  • Eagerly Performing ASP.NET MVC 3 Unobtrusive Client Side Validation

        Introduction:

              Unobtrusive client side validation is one of the great feature that I like in ASP.NET MVC 3. Unobtrusive client side validation feature uses the famous jQuery validation plug-in internally. Jquery validation plug-in perform client side validation lazily. What does this means? This simply means that before submitting the form for the first time, the user can tab through fields without getting any error message. This makes sense and lot of developers and designers like this behavior. But guys coming from places where validation is performed when fields focus out, may not like this behavior. In this article, I will show you how to perform validation on fields when fields focus out.

  • Unobtrusive Client Side Validation with Dynamic Contents in ASP.NET MVC 3

        Introduction:

              A while ago, I blogged about how to perform client side validation for dynamic contents in ASP.NET MVC 2 at here. Using the approach given in that blog, you can easily validate your dynamic ajax contents at client side. ASP.NET MVC 3 also supports unobtrusive client side validation in addition to ASP.NET MVC 2 client side validation for backward compatibility. I feel it is worth to rewrite that blog post for ASP.NET MVC 3 unobtrusive client side validation. In this article I will show you how to do this.

  • Moving ASP.NET MVC Client Side Validation Scripts to Bottom

    Introduction:

              ASP.NET MVC 2 makes it very easy to enable client side validation in your application, due to which your application users will see the feedback immediately before your form will submit anything to the server. ASP.NET MVC 2 enable client side validation by emitting client side script immediately after the form close tag. But due to performance, developers likes to emit inline script as low in the page as possible, as explained at here. There is another concern of inline script is that javascript that is embedded in the HTML of the page can be seen by search engines. This could be a concern for SEO. For detail of this please see this. Therefore in this article I will show you how to move inline scripts (which is emitted by ASP.NET MVC to enable client side validation) to the bottom. 

  • 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.