Dapper.NET is not just another ORM tool, it’s considered as the king of ORM. Because it’s fast, easy to integrate, requires fewer lines of code, supports bulk data insertion and supports static and dynamic object binding. And Dapper ORM can be used with .NET. So in this post, let’s find out how to use Dapper ORM with ASP.NET Core for CRUD operations.
Read More
Tag: ASP.NET Core Web API
Integrate HangFire With ASP.NET Core WEB API
HangFire is an easy way to perform background processing in .NET and .NET Core applications. There isn’t any need to have a separate windows service or any separate process. Hangfire supports all kinds of background tasks – short-running and long-running, CPU intensive and I/O intensive, one shot and recurrent. You don’t need to reinvent the wheel – it is ready to use. In this post, we will see how to integrate HangFire with ASP.NET Core WEB API. Read More
Global Exception Handling in ASP.NET Core WEB API
Exception handling is one of the most important part of any application that needs to addressed and implemented properly. With ASP.NET Core, things have changed and are in better shape to implement exception handling. Implementing exception handling for every action method in API, is quite time-consuming and requires extra efforts. So in this post, find out how to implement global exception handling in ASP.NET Core WEB API. Read More
Accept only int value for ASP.NET Web API action method parameter
In this short post, find solution to how to accept only int value for ASP.NET Web API action method parameter. Below is an example of Web API action method which accepts an int type parameter. And it returns the same value as response.
// GET api/values/5 [HttpGet("{id}")] public string Get(int id) { return id.ToString(); }
So when you hit http://localhost:59845/api/values/5
, you get “5” returned in response. And when you hit http://localhost:59845/api/values/abc
, then you get “0” as returned. But what if, you want to accept only integer value and if input parameter is not “int” then return a 404 error.
With attribute routing, you can also define the data type constraint for parameter. So updated action method is,
// GET api/values/5 [HttpGet("{id:int}")] public string Get(int id) { return id.ToString(); }
So now when you hit http://localhost:59845/api/values/abc
, then you shall get 404 error. You can use any data type for route constraint as per your requirement.
Hope you like it. Stay tuned for more!.
Cascading DropDown List with ASP.NET Core WEB API and Angular 2
Earlier I posted about Cascading DropDown List using Angular 2 and in this post, we take it to next level and implement it with ASP.NET Core Web API and Angular 2. But starting/configuring AngularJS 2 with ASP.NET Core is not straightforward and it requires some manual configurations to be done. If you are not sure how to do it, I recommend you to read this helpful post to find out post how to start with Angular 2 in ASP.NET Core with TypeScript using Visual Studio 2015.
Read More