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. (more…)
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.
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.
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.
In this short post, find the code to disable Anti-forgery token validation globally in ASP.NET Core Razor pages. If you are new to Razor Pages, It’s a new feature of ASP.NET Core that makes coding page-focused scenarios easier and more productive. Razor pages use handler methods to deal with the incoming HTTP request (GET/POST/PUT/Delete). (more…)
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. (more…)