Thoughts on .Net & Coding

.Net Articles, tutorials, reviews, code and more...

  • Optimize ASP.NET MVC Views with Bundling and Minification Features

    ASP.NET MVC web applications often use client side scripting in one or the other way. Use of JavaScript libraries such as jQuery and frameworks such as AngularJS is quite common these days. Therefore it is important to pay attention to the rendering of the views. Especially, script load time is worth some consideration. Luckily, ASP.NET MVC offers help in the form of bundling and minification features. This article shows how these features can help you optimize the views.

    Read more...

  • Understanding JavaScript Prototypes (and creating your own "$" library)

    Many web applications developed today use some or the other JavaScript library or framework. These libraries and frameworks heavily rely on what is known as JavaScript prototypes. Therefore, it would be interesting to any web developer to understand this concept. This short article explains in brief what JavaScript prototypes are and how they form an integral part of many of the popular JavaScript libraries. You also learn to create your own "$" library.

    Read more...

  • Implementing Sorting and Paging in Web API using OData queries

    The client displaying data returned by a Web API may want to implement sorting or paging on the data being returned. Although there can be different ways to implement these features, a simple technique is to use OData support offered by the Web API. This article shows how to call a Web API by using a client-side script and also shows how to implement Ajax-driven sorting and paging.

    Read more...

  • Implementing Sorting and Paging in ASP.NET MVC

    Displaying records in a table is a very common requirement in many web applications. Such a table also needs facilities such as sorting the data based on a specific column and pagination for the sake of easy navigation and display. Unlike ASP.NET web forms, MVC doesn't have readymade server controls such as GridView to ease your job. One needs to either use a third-party helper or make some custom provision to accomplish this task. This article shows how persistent and bidirectional sorting as well as paging can be implemented in ASP.NET MVC without any external dependencies.

    Read more...

  • Display image from byte array in ASP.NET MVC

    Displaying images from wellknown URLs is quite straightforward. At times, however, you need to display images that are available as raw binary data. Consider, for example, that you are building a Captcha system that generates images on the fly. These images won't reside on the server as physical files. They will be generated and held in memory using System.Drawing classes (or something similar). To display them you can't point the src attribute of an <img> element to a particular URL as such.

    Read more...

  • Learn ASP.NET MVC, jQuery, AngularJS & HTML5 in Thane. Registration started for November 2014 batches!

    We will be conducting a 5 day intensive training programs on ASP.NET MVC, jQuery, AngularJS and HTML5 in the month of November 2014. Small batches, personal attention and real world examples. Registration has already started. In case you or your friends are interested to join please get in touch with us as soon as possible. The courses are conducted in Thane. You may read more details here.

    Read more...

  • Securing ASP.NET MVC Applications with ASP.NET Identity

    ASP.NET offers Forms Authentication as one of the authentication schemes. Developers often use Forms Authentication in combination with membership, roles and profile features to provide security to their web applications. Over the years the needs of authentication schemes used in a web application have changed. To take into account these changing trends Microsoft has released ASP.NET Identity - a new way to authenticate users of your web application. This article describes how ASP.NET Identity can be used in an ASP.NET MVC application from the ground up.

    Read more...

  • Using Display Templates and Editor Templates in ASP.NET MVC

    ASP.NET MVC developers often use HTML helpers such as LabelFor() and TextBoxFor() to display model properties on a view. Although this approach works fine in many situations, it proves to be inadequate when you wish to customize how data is presented to the user for displaying and for editing. Luckily, you can use display templates and editor templates to overcome this limitation. This article discusses what display templates and editor templates are and how to use them in an ASP.NET MVC application.

    Read more...

  • Learn ASP.NET MVC in Thane. Registration started for October 2014 batches !

    We will be conducting a 5 day intensive training program on ASP.NET MVC in the month of October 2014. Learn MVC5, EF6, Web API 2, VS2013 and more. Small batches, personal attention and real world examples. Registration has already started. In case you or your friends are interested to join please get in touch with us as soon as possible. The courses are conducted in Thane. You may read more details here.

    Read more...

  • Wrapping multiple calls to SaveChanges() in a single transaction

    When you make any additions, modifications and deletions to an Entity Framework DbSet and call SaveChanges(), EF starts a new transaction and executes all the INSERT, UPDATE and DELETE operations inside that newly created transaction. If the call to SaveChanges() succeeds the underlying transaction is committed, otherwise the transaction is rolled back. In some cases you may want that multiple calls to SaveChanges() be executed in the same transaction. Luckily, Entity Framework 6 provides an easy way to accomplish the same.

    Read more...