Tag: ASP.NET MVC 5
-
How to Implement the Repository Pattern in ASP.NET MVC Application
Read full article on the Infragistics blog The Repository Pattern is one of the most popular patterns to create an enterprise level application. It restricts us to work directly with the data in the application and creates new layers for database operations, business logic and the application’s UI. If an application does not follow the…
-
What are ViewData, ViewBag, and TempData in ASP.NET MVC?
I have often seen entry level developers struggle with the differences between and usage of ViewData, ViewBag and TempData in ASP.NET MVC. And while there are many articles and blog posts on this topic out there, I’ll try to explain it simply. To start with, ViewData, ViewBag, and TempData all three are objects in ASP.NET…
-
Child Actions in ASP.NET MVC
Read full post on falafel blog Child Actions are the action methods which can be invoked within the view. This is used to work with the data in the view, which are not related to the main action method. For example, if you want to create a data driven widget in the view using data…
-
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…
-
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…
-
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…
-
Customize the MVC 5 Application Users’ using ASP.Net Identity 2.0
In this post you will learn to customize users’ in ASP.Net MVC 5 app using ASP.Net Identity 2.0