Exception handling in ASP.NET MVC applications

For exception handling we have been using try..catch..finally block since forever in various languages. In this blog we will see how to handle the unhandled exceptions in ASP.NET MVC. Unhandled exceptions are the exceptions that are not handled using try..catch..finally block. For handling unhandled exceptions or for creating a global exception handler we have to perform following steps:

1. In web.config add following line in the system.web section

<customErrors mode=”RemoteOnly”></customErrors>

2. Before each controller add following annotation:


public ActionResult Index()

3. In Views folder create a sub-folder named Shared and create a file there named Error. Extension can be .cshtml (razor) or .aspx (web forms engine)

4. Optionally to the Error file add following code to display the actual error message:



In case if you want to name the Error page something else then change the annotation before controller to [HandleError(View=”custom_name”)]. Replace custom_name with whatever your error page name is.

New SharePoint CSOM version released for SharePoint Online

SharePoint supports two main development / deployment techniques for creating SharePoint projects: Server Object Model and Client-Side Object Model. If you plan on doing development for the hosted version of SharePoint, i.e. Office 365 / SharePoint Online, then you CSOM is the only option. A new SharePoint CSOM has been been released for SharePoint Online / Office 365. It also allows development for Project Online (hosted Project Server). It can be downloaded using “Manage NuGet Packages” option in Visual Studio. Just search for the id “Microsoft.SharePoitOnline.CSOM” and VS will download the required files.

Microsoft has acquired Xamarin

Xamarin has been known for offering a native cross-platform development solution. It allows writing code using .NET and then running the same code on iOS, Android and WIndows devices. Microsoft has been supporting Xamarin tools in Visual Studio since VS 2013. But, now Microsoft has purchased Xamarin. It might boost Windows phone development and we might see more apps coming over to Windows. Even if Windows Phone apps don’t become popular it would still let .NET developers create cross-platform apps.