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 … Continue reading Custom Action Filter in ASP.NET MVC 5

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 … Continue reading Convert User to ApplicationUser in ASP.Net MVC

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 … Continue reading How to get current user in ASP.Net MVC 5

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 … Continue reading RedirectToAction or View as ActionResult in ASP .Net MVC5 ?

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 … Continue reading Fetching Image from database in ASP.NET MVC 5 application

Attribute Routing in ASP.NET MVC 5

ASP.NET MVC 5 introduced Attribute Routing. It allows you to apply a route directly on the controller class. Before we use the Attribute Routing, let’s relook how the convention based routing works. We create a route as follows: Index action of Home controller can be accessed on two different URLs. Either using the base URL … Continue reading Attribute Routing in ASP.NET MVC 5

Work with ASP.NET MVC 5 Areas from different projects

Read full article on Falafel blog While working on an ASP.NET MVC 5 application, I came across a requirement to use an Area from one project in another project. For example: I have a project A and a project B. I need to use an Area which is part of project B inside of project … Continue reading Work with ASP.NET MVC 5 Areas from different projects

User Instance login flag is not allowed when connecting to a SQL Server instance: Solved

While working with an ASP.NET MVC application I encountered following exceptions: Exception clearly says that user instance login flag is not allowed when connecting to a SQL Server instance. For sure this error is related to SQL Server instance I am working on in this particular application. I examined the connection string in the web.config … Continue reading User Instance login flag is not allowed when connecting to a SQL Server instance: Solved