Posts

HandleErrorAttribute OR Error Handling in MVC 4

Image
HandleErrorAttribute in MVC is used to display friendly error pages to user when something goes wrong in the application. Let’s create a simple exception in the application to explore HandleErrorAttribute.

Various ways to pass data from Controller to View in MVC

Image
There are various ways to pass data from a Controller to a View. I'm going to discuss how Controllers interact with Views and specifically cover ways you can pass data from a Controller to a View to render a response back to a client. So, let's get started.

What happens when database doesn't match conventions / using OnModelCreating() feature?

Image
This is just basic article and I’m not going to say anything new here but I will say things in my way.  The very well-known question newbies ask about MVC and Entity Framework is, how does a conceptual database model target the names?

MVC Bind Attribute like [Bind(Exclude = "Name")] or [Bind(Include = "Address, Payment, EmailID")]

Image
When we have an ASP.NET MVC View that accepts user input and posts those inputs to a server we have the option to use the built-in Model-binding features to provide more control and security, we can restrict the properties that are allowed to be bound automatically.

The name 'Scripts' does not exist in the current context

Image
There is a very small bug in the MVC 4 Empty Template that can be seen when you create a new MVC 4 Application with an "Empty" template and start adding views for CRUD operations (using scaffolding). And when you run the application and try to navigate (to  http://localhost:port/controller/Create  or  http://localhost:port/controller/Edit ) in "Edit.cshtml" and "Create.cshtml" views, you get the following error:

Creating ASP.NET WebApplication/ASP.NET MVC Application Membership Database on SQL Server rather than LocalDb

Image
I was asked this question from one of my blog reader: How can a DB be created in SQL Server rather than locally (LocalDb) which is default?

Using image with HtmlHelpers or @Html.ActionLink

Image
Sometimes we need to serve image with the link and with the release of Razor syntaxes we have HtmlHelpers like Html.ActionLink() that has nothing like image.

Popular posts from this blog

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Customize User's Profile in ASP.NET Identity System

Lambda two tables and three tables inner join code samples