Razor Pages are 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). These are similar to Action methods of ASP.NET MVC or WEB API. Razor Pages follow particular naming convention and that is also true for Handler methods. They also follow particular naming conventions and prefixed with “On”: and HTTP Verb like OnGet()
, OnPost()
etc. The handler methods also have asynchronous version: OnGetAsync()
, OnPostAsync()
etc. Calling these handler methods from jQuery Ajax is tricky. This post talks how to handle Ajax requests in ASP.NET Core Razor Pages. Read More
Tag: ASP.NET Core
Quick summary of what’s new in ASP.NET Core 2.0
ASP.NET Core 2.0 Preview 1 is already out and you can start building application with ASP.NET Core 2.0. At the time of writing this post, it is still in Preview 1 and final version is expected to be released in Q3-2017. To build ASP.NET Core 2.0 based application, you need to install Visual Studio 2017 Preview 3. Since this is a major release, expect some code breaking changes and a few new pieces. In this post, I try to put together a quick and short summary of what’s new in ASP.NET Core 2.0 compared to ASP.NET Core 1.1. Read More
How to Compress and Resize/Scale Images in ASP.NET Core
Large size images are slow to load and optimizing them can reduce bandwidth and help your website load faster. TinyPNG is a great place to compress JPEG or PNG images. In fact, we always use TinyPNG to compress images, created for this blog. Along with web interface, they also expose REST API (Free/Paid) to compress images on the fly. In this post, let’s find out how to compress and resize/scale images in ASP.NET Core using TinyPNG API.
Read More
How to upload file via Swagger in ASP.NET Core Web API
Swagger is a simple, clean and powerful representation of your RESTful API. Once integrated with WEB API, it provides a UI which helps in testing the API with ease. In my earlier post, I explained about how to integrate swagger with the ASP.NET Core Web API. And it works great with all HTTP verbs and input parameters. But uploading a file via Swagger is not straightforward. In this post, let’s find out how to upload file via Swagger in ASP.NET Core Web API. Read More
Response Caching in ASP.Net Core 1.1
With the ASP.NET Core 1.1 release, many new features were introduced. One of them was enabling gZip compression and today we will take a look at another new feature which is Response Caching Middleware. This middleware allows to implement response caching. Response caching adds cache-related headers to responses. These headers specify how you want client, proxy and middleware to cache responses. It can drastically improve performance of your web application. In this post, let’s see how to implement response caching in ASP.Net Core application. Read More
How to enable gzip compression in ASP.NET Core
ASP.NET Core 1.1 has an inbuilt middleware for Response compression, which by default uses gzip compression. All modern browsers support response compression, and you should take advantage of it. Instead of sending response from the server as it is, it’s better to compress it and then send it, as this will reduce the response size and provides better speed. So in this post, let’s see how to enable gzip compression in ASP.NET Core. Read More
Use NPoco ORM With ASP.NET Core
NPoco is a simple C# micro-ORM that maps the results of a query onto a POCO object. NPoco is a fork of PetaPoco with a handful of extra features. And NPoco ORM can be used with .NET Core. So in this post, let’s find out how to use NPoco ORM with ASP.NET Core for CRUD operations.
Read More