Nullable Date Format in C#

If we have to format the Nullable Date in C#, We can do like this

DateTime? date = new DateTime(2021, 05, 10, 22, 45, 12, 004);
//Will through exception
// string date_str = date.ToString("dd/MM/yyyy");

//Working Syntax:
string date_str= (date != null ? date.Value.ToString("dd/MM/yyyy") : "n/a");


How to implement EF database first approach in Core Blazor ?

Step 1: Create the database as per as your requirement
Step 2: Install the EF Core Power Tool in Visual studio like this

Step 3: Go to the solution explorer and right click on it then EF Power Tool then Reverse Engineer as given below image

Solution Exp

Step 4:  Select the database name like this

database name

then click on OK

Step 5: Select all the required table which one we are going to use in application

Step 6:  Now Select the namespace and context name like given below


Step 7 : Click on OK. Now this tool will generate the required model and context file in Data folder.

How to handle page not found exception message in MVC 5.0 in user friendly ways

If we have mvc 5.0 application and we are searching some different page on browser then we will get the exception message.

“The resource cannot be found” I.e HTTP 404 status code.

To display this error message as user friendly we can install the “NotFoundMVC” Nuget package in Visual studio like this


Now go to the web config file and delete the this line of code. This is the problem in this NuGet package, which is creating some invalid code in web config file.


Now this package will create the Not found page for you.

This will also add the required code in web config file like this

Now run the application with wrong controller/Action name. It will give user friendly error message like this

Limitation of Control
This control does not handle the other error message. It will handle on status code 404. For other error we have to implement separate error handle approach.

I hope this post will help to implement the user friendly error message for http status code 404.