Skip to main content

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

Enforce HTTPS in ASPNET Core Razor Pages

Enforce HTTPS in ASP.NET Core Razor Pages

Razor Pages are a new feature of ASP.NET Core 2.0 that makes coding page-focused scenarios easier and more productive. Razor Pages are introduced with the intent of creating page focused scenarios where there is no real logic is involved. You can find all my razor pages posts here. The latest version (2.1) of ASP.NET Core supports HTTPS by default, but at the time of writing this post, it is still in the preview release. You can find all my ASP.NET Core 2.1 posts here. The app built on ASP.NET Core 2.0 version needs to be secured manually. In this post, we will see how to enforce HTTPS in ASP.NET Core Razor Pages applications. Read More

Validate Model State automatically in ASP.NET Core 2.0

A ModelState is a collection of name and value pairs submitted to the server during a POST request. It also contains a collection of error messages for each value. The Modelstate represents validation errors in submitted HTML form values. Model validation is the first statement in each controller action method to check for any error before moving forward. A familiar piece of code.

The IsValid property will be true when the values are attached correctly to the model AND no validation rules are broken in the binding process. However, writing this piece of code in every action method increases efforts, lines of code and repetitiveness. It would be appropriate to make model validation a reusable piece or even better would be to automate this process. This post talks about how to validate model state automatically in ASP.NET Core 2.0.
Read More

Create Petstore like Swagger UI for ASP.NET Core WEB API

Swagger doesn’t need an introduction as it is the world’s largest framework of API developer tools for the OpenAPI Specification(OAS), enabling development across the entire API life-cycle, from design and documentation, to test and deployment. Swagger is an UI representation of your RESTful API. It allows anyone — be it your development team or your end consumers — to visualize and interact with the API’s resources having none of the implementation logic in place. The Petstore (created by the swagger team) is a demonstration of the beautiful Swagger UI. You can easily integrate the Swagger in your application, but the sad part is you will get a different UI, not same as available @ Petstore. In this post, let’s find out how to create Petstore like Swagger UI for ASP.NET Core WEB API.
Read More

Define a custom environment in ASP.NET Core

One of the cool features of ASP.NET Core is, Hosting Environment Management. It makes life easy for the developers, while dealing with multiple environments. Previously, the developers have to build the application differently for each environment (Staging, UAT, Production) due to dependency on config file sections and the preprocessor directive applicable at compile time. It’s a time-consuming and painful process. ASP.NET Core takes a different approach and offers a new way to save developers from all this hassle. Read More

Create an Angular 5 app in 5 steps using dotnet cli

Earlier I posted about creating an Angular 4 app with Visual Studio 2017 and then also talked about upgrading the same Angular 4 app to Angular 5 with Visual Studio 2017. Recently, ASP.NET team released release candidate version of Single-Page Application templates. These templates allow developers to create SPA application based on Angular, React, and React with Redux. At the time of writing this post, the final version is scheduled to release in Early 2018. This post shows how to create an Angular 5 app in 5 steps using dotnet cli. Read More