ASP.NET Core 2.1 introduced the APIController
attribute which performs automatic model state validation and in case of an invalid model state, responds with a 400 bad request error. When the controller is decorated with APIController
attribute, the framework would automatically register a ModelStateInvalidFilter
which runs on the OnActionExecuting
event. This checks for the model state validity and returns the response accordingly. This is a great feature, but sometimes you want to return the custom error instead of the 400 bad request error. In such case, we should disable automatic model state validation.In this post, find out how to disable automatic model state validation in ASP.NET Core 2.1.
Tag: ASP.NET Core 2.1
Add Angular 6 Material to Angular 6 and ASP.NET Core app
Angular material is material design components for the Angular application to create comprehensive, modern UI components that work across the web, mobile, and desktop. Earlier, I posted about how to create an Angular 6 app with Visual Studio 2017 & ASP.NET Core and also posted about implementing ASP.NET Core SPA template features. In this post, we’ll see how to add angular 6 material to angular 6 and ASP.NET Core app. The steps given in this post are also applicable for any standard angular 6 application. Read More
How to increase file upload size in ASP.NET Core
ASP.NET Core 2.0 enforces 30MB (~28.6 MiB) max request body size limit, be it Kestrel and HttpSys. Under normal circumstances, there is no need to increase the size of the HTTP request. But when you are trying to upload large files (> 30MB), there is a need to increase the default allowed limit. In this short post, we’ll see how to increase file upload size in ASP.NET Core application and various options to control this restriction. Read More
3 ways to use HTTPClientFactory in ASP.NET Core 2.1
Microsoft introduced the HttpClient in .Net Framework 4.5 and is the most popular way to consume a Web API in your .NET server-side code. But it has some serious issues like disposing the HttpClient object doesn’t close the socket immediately, too many instances affecting the performance and Singleton HttpClient or shared HttpClient instance not respecting the DNS Time to Live (TTL) settings. HttpClientFactory solves the all these problems. It is one of the newest feature of ASP.NET Core 2.1. It provides a central location for naming and configuring and consuming logical HttpClients in your application, and this post talks about 3 ways to use HTTPClientFactory in ASP.NET Core 2.1. Read More
ActionResult<T> in ASP.NET Core 2.1
One of the new features of ASP.NET Core 2.1 is, a new type called ActionResult<T> that allows you to return either the response type or any action result, while still indicating the response type. In this short post, we’ll see how this new type ActionResult<T> in ASP.NET Core 2.1 can be used and what issue it addresses. Read More
Implement ASP.NET Core SPA template features in an Angular 6 app
Earlier, I posted about creating an angular 6 based app with VS 2017. It’s a pure Angular 6 app and doesn’t use features comes with the ASP.NET Core SPA template. At the time of writing this post, default ASP.NET Core SPA template for angular points to angular 5. The SPA template uses angular on the client side and ASP.NET Core as back-end. It uses a package Microsoft.AspNetCore.SpaServices
as a middleware to provide different configurable options for your application such as HMR (Hot Module Replacement), Routing Helper, SSR (Server Side Rendering) etc.. In this post, let’s find out how to create an angular 6 app with ASP.NET Core 2.1 and implement ASP.NET Core SPA template features in the same app. Read More
How to create an Angular 6 app with Visual Studio 2017
At the time of writing this post, default ASP.NET Core SPA templates allow you to create Angular 5 based app with Visual Studio without installing any third-party extensions or templates. Angular 6 is out now and you can also upgrade the Angular 5 app to Angular 6. What if you want to create Angular 6 app with VS 2017? This post talks about how to create an Angular 6 App with Visual Studio 2017 and how to extend it with a simple example. Read More