Year: 2014
-
Start-up code using WebActivator in MVC application
Read full post on Falafel blog WebActivator allows us to execute a code long before application start-up. There may be requirements when you need to load external assemblies or instantiate a particular object before the application start up. You need to make sure some codes execute before the codes inside the App_Start folder and the…
-
Seed the database with initial Users in MVC 5
Read full article on Falafel blog In MVC 5 applications you may want to seed the database with initial users for various reasons. You may want default users and roles added as part of the application. In this post, we will take a look at how to seed the database with default users.The MVC…
-
Custom Action Filter in ASP.NET MVC 5
Read full article on Falafel blog here ASP.NET MVC 5 provides five different kinds of Filters. They are as follows: Authentication [Introduced in MVC5] Authorization Action Result Exception Filters are used to inject logic at the different levels of request processing. Let us understand where at the various stages of request processing different filters get…
-
What is Azure DocumentDB
Read full article on Falafel blog here Recently I attended Cloud Camp by Microsoft India in Delhi. I had good time learning at the event. Besides other Microsoft Azure services like Azure Websites, Azure Mobile Services and Azure DocumentDB impressed me lot. In this post, I am sharing first level learning on Azure DocumentDB. Azure…
-
Convert User to ApplicationUser in ASP.Net MVC
In the last post I talked about How to get current user in ASP.Net MVC 5 . Type of the current user is IPrincipal which is shown as follows: You may come across requirement to work with ApplicationUser which is created as follows: You can covert returned User to ApplicationUser as follows: To convert create…
-
How to get current user in ASP.Net MVC 5
There are two simple ways to get current user in MVC 5. If you are inside the controller class current user can be fetched as follows, Do not forget to add namespace, Other scenario could be that you are not inside the controller class and want to fetch the user information. You can fetch…
-
RedirectToAction or View as ActionResult in ASP .Net MVC5 ?
We have often seen action returns a View method. Optionally we can also pass the view name and the other parameters in the View method. Most of the time we return a view as ActionResult to navigate. Now I have a requirement to navigate to Login view or return Login view on the basis of…
-
Decorator Pattern in C#
Read full article on Falafel blog “Decorator pattern attach additional functionalities or responsibilities to an existing object at the runtime”. It adds new behaviour to an individual object without affecting other objects of the same class. New behaviour or functionalities can be either added dynamically at the run time or statically. The decorator pattern: ·…
-
Fetching Image from database in ASP.NET MVC 5 application
In this post we will learn to fetch image from a database. I have taken Northwind database as an example. Employee table of the Notrhwind database stores a Photo using the Image type. We will fetch data from the Photo column (type: Image) in the MVC application. Let us start with the Controller. In the…