Category: JumpStart


JumpStart # 30– Create Azure Cloud Service Package (CSPKG) of Visual Studio 2013 project solution using PowerShell

There can be scenarios where we need to have control on building the Azure Cloud Service Packages, say for example when we want to dynamically override some files in the project and build the package on the fly. In this short tutorial, we are going to see how to create a CSPKG file, which can be deployed to a Azure Cloud Service. Although Windows Azure PowerShell Cmdlets provide an option Save-AzureServiceProjectPackage to create a package file for a cloud project, this cmdlet is NOT (atleast with Windows Azure PowerShell 0.7.1 version) going to work for the project solutions which are created using Visual Studio IDE. Save-AzureServicePRojectPackage is only going to work for solutions which are created using cmdlets.


JumpStart # 29– Remote Debugging an AzureWebsite from Visual Studio 2013

With the new release of Windows Azure SDK 2.2 for Visual Studio 2013, we can now remotely debug all the application in the cloud in a easier way. In this short tutorial I am going to show on how to remotely debug a website which is hosted in Windows Azure in simple steps. Prerequisite for this tutorial is Windows Azure SDK 2.2, anyone can download it from Microsoft Windows Azure Downloads.


JumpStart # 22– Image preview for input file type using HTML5 File API

In this short tutorial we are going to see how to preview an image when selected for upload using input file type. We use HTML5 File API and its FileReader to read the file and display it in the image tag. FileReader’s readAsDataURL will start reading the contents of the specified Blob, which may be a File. When the read operation is finished, onloadend callback will be called and the raw binary data of the file contains in the result attribute.


JumpStart # 19– Setting up Dependency Injection for ASP.Net Web API

We use Unity IoC container to achieve dependency injection for Web API. Create a ASP.Net MVC4 Project and its associated Class Library as shown in this tutorial –

Instead of installing Unity.Mvc3 Nuget Package, install Unity.WebAPI Nuget Package.


JumpStart # 18– Deferred validation in ASP.Net 4.5 using requestValidationMode

In ASP.Net 4.5, we can defer (lazy) validation of form fields by setting requestValidationMode attribute in httpRuntime section of web.Config file. By default, all the data coming through in request is subjective for validation. But if we want to defer the validation for form fields until they are accessed at runtime, we can set requestValidationMode attribute along with ValidateRequestMode to disabled for the controls of our interest.


JumpStart # 17–Difference between IEnumerable<T> and IQueryable<T> in EntityFramework SQL

IQueryable basically generates the complete expression tree and then executes it to get results, where are it is not true in IEnumerable scenario. But still IQueryable is inherited from IEnumerable. IQueryable’s extension methods take expressions based on which expression trees are build, while for IEnumerable’s extensions methods takes functions based on which results are enumerated and published. From afore said reasons, IEnumerable is better on Collections stored in memory, where as IQueryable can optimize performance of Remote Data Sources like Databases.


JumpStart # 16–Lazy Loading using Lazy<T> in C# 4.0

From C# 4.0, .Net Framework supports Lazy initialization of instances. Lazy initialization helps in loading instances (especially useful for costly properties of objects) only when they are accessed at runtime. That means lazy properties are not loaded when actual object initialization is done.


JumpStart # 15–Unobstructive Validation in ASP.Net 4.5

ASP.Net 4.5 supports UnObstructive JavaScript validation on client side with UnobtrusiveValidationMode=”WebForms” attribute on page level. With this advancement, page size will reduce drastically for a page which contains large number of validation controls.

Unobstructive Validation removes inline JavaScript which is generated by regular ASP.Net Validators, instead it uses HTML5 Data attributes to perform validation.


JumpStart # 14–Strongly typed Data Controls in ASP.Net 4.5

ASP.NET 4.5 provides an ability to declare the data type of the data that a control is bound to throught ItemType property. When we set this property, two new typed variables are available in the scope of data-binding expressions: Item (One Way binding) and BindItem (Two Way Binding).

In previous versions, Data binding expressions are evaluated at runtime using reflection and bind data, which is not only developer nightmare but also encourages more data shaping problems.


JumpStart # 13–Async HttpHanlders in ASP.Net 4.5

ASP.NEt 4.5 introduces Async processing of Asynchronous HttpHandler using “HttpTaskAsyncHandler” abstract class and then override “ProcessRequestAsync”. HttpTaskAsyncHandler implements both IHttpAsyncHandler, IHttpHandler. In this new way, ASP.Net takes most of the overload of managing threads in continuing async tasks by itself.


JumpStart # 11 – Xml Comments for code using GhostDoc Extension

Documentation of code, arrrgh!!! :-) Most of us hate it, but believe me its an important part in SDLC. Especially when it comes to maintenance of legacy code, Documentation is a life savior.

Writing Xml Comments in Visual Studio is not going to be a easy going task (for large projects it’s a nightmare too). So I started using GhostDoc, an extension of Visual Studio, which helps and makes Xml commenting comparatively easier. There are many other extensions available which give the same functionality in writing comments, but in this small JumpStart I would like to show how to get started with GhostDoc.


JumpStart # 10 – Display Validation Error Messages in different formats using JavaScript

At times, instead of normal display of validation error messages (or even in the validation summary) on the page, we tend to display them in more user friendly manner. This Jumpstart deals with the using JavaScript to get the above shown validation error display formats. The main concentration laid on especially 3 different formats – 1) Water Marking 2) Error Images (beside TextBox) and 3) Alert Dialog. The before mentioned effects can be easily achieved with some quick JavaScript. In this tutorial, we use 3 JavaScript functions to get more flexible user interactivity with the page, they are – validate(), resetValidation(event) and singleValidation(event). In the following code sample we use three simple TextBox and RequiredFieldValidator pairs to demonstrate the validation error effects.


JumpStart # 9 – Make Response.Redirect() open in New Blank Window

1) The main motive behind writing this code snippet is that this topic has been asked number of times @forums.
2) Response.Redirect() by itself never opens a page in a new blank window, so the trick lies in using the JavaScript. We use the OnClientClick property of the Button to open a new window.
3) The credit of the code goes to a MSFT (I never knew his name) for providing this sample @forums.