Converting DataTable to Generic List

Code snippet for converting a DataTable to Generic List. public static List<TEntity> ToList<TEntity>(this DataTable dataTable, Dictionary<string, string> mapping) where TEntity : new() { var list = new List<TEntity>(); foreach (DataRow dataRow in dataTable.Rows) { var entity = new TEntity(); foreach (var keyvaluePair in mapping) { var property = entity.GetType().GetProperty(keyvaluePair.Key, BindingFlags.IgnoreCase...


TagHelpers in ASP.NET 5

TagHelpers is a new feature in ASP.NET, it is similar to HTML helpers, which already available in ASP.NET MVC. Similar to HTML helps TagHelpers allows to process server side content on HTML controls. So <a asp-controller="Home" asp-action="Index">Home</a> Will be rendered as [Home](/Home/Index) It looks similar to ASP.NET controls but it...


Continuous Deployment (GitHub) with Azure Web Sites

Windows Azure websites supports Continuous Deployment. Continuous Deployment can be thought as an extension of continuous integration, where when ever users commit a changeset, build will be triggered. And in case of Continuous Deployment, the changes will be published to your live application directly from source control, when ever user...


Azure-System.MethodAccessException: Attempt by security transparent method

Today I faced a strange issue, after publishing an empty ASP.NET MVC application to Azure WebSite. When I tried to browse the page I got an exception like this - Attempt by security transparent method ‘System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’ to access security critical method ‘System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)’ failed. Here is the screenshot This issue...


View Components in ASP.NET MVC 6

In ASP.NET MVC 6, Microsoft introduced View Components, which similar to partial views, but they are much more powerful. It is like a mini controller, which helps to render a part of response rather the whole response. View Components consists of two parts, a class, derived from ViewComponent class(Similar to...


Cookie Authentication in ASP.NET 5

This post is about cookie based authentication in ASP.NET 5. I am implementing a cookie authentication in ASP.NET MVC application. Similar to other middleware components in ASP.NET, Cookie Authentication is also a middleware component, which you need to plug into ASP.NET pipeline. For implementing cookie authentication, you require reference of...


Sending email message using Exchange Web Service Managed API

Microsoft Exchange Web Services (EWS) is an interface by which you can programmatically manage Exchange items such as calendar, contact, and email. Microsoft Exchange Web Services is an Application Programming Interface (API) that provides programmatic access to the information and business logic in Microsoft Exchange Server 2007 or later versions....