Razor Pages

Cannot convert from 'long?' to 'long'

I use a code similar to the following to accept the value for a query string named Id on one of my pages of a .NET Razor Page application. It is an optional query string. Its value is then passed to another function for further processing. When I compile the code, I get the error message "cannot convert from 'long?' to 'long'"

Tags:  Troubleshooting

Implementation of Custom Server-Side Validation Rules in ASP.NET

We use validation attributes in ASP.NET Core to validate model properties. These validation attributes are available in System.ComponentModel.DataAnnotations namespace. Even if there are many built-in validation attributes, we will sometimes have to use custom validation attributes to enforce our business rules. This article explains how it can be done.

Unable to resolve service for type 'System.Net.Http.HttpClient' while attempting to activate... error

When I tried to register a service that uses an object of System.Net.Http.HttpClient  for dependency injection, I got this error "Unable to resolve service for type 'System.Net.Http.HttpClient' while attempting to activate "

Tags:  Troubleshooting

Server Side Pagination Using Stored Procedure and Dapper in ASP.NET Core Razor Pages

This article explains how paging can be implemented using the stored procedure in ASP.NET Core Razor Pages. When you have millions of records in the database and need high performance and complete control over the query to be used for pagination, you can use stored procedures.

Tags:  Razor Page PaginationPagination

Code Snippet to Create a Checkbox List in an ASP.NET Core Razor Page Application

Checkbox lists are useful when you want to allow users to select more than one predefined option. This article explains how a Checkbox list can be generated, and the selected checkbox values can be retrieved when the page is submitted in an ASP.NET Core Razor Page application.

HTTP Error 500.34 - ASP.NET Core does not support mixing hosting models

"HTTP Error 500.34 - ASP.NET Core does not support mixing hosting models". You will get this error if you host two .NET Core web applications in the same application pool using In-process hosting. This error can be fixed using two methods. One solution is using different application pools for the web applications.  The other solution is changing the hosting model of the applications to "OutOfProcess". 

Tags:  Troubleshooting

HTTP Error 500.30 - ASP.NET Core app failed to start

You may see an HTTP 500.30 error when your ASP.NET Core web application fails to start. This article explains how you can check the error details when you don’t have access to IIS and the web server.

Tags:  Troubleshooting

Pagination in ASP.NET Core Razor Pages using custom Tag Helper

This article explains how custom Tag Helpers can be used to develop reusable paging code for .Net Core Razor Page applications. It is highly customizable so that you can use CSS classes to modify the look and feel of the paging links and mention the number of links to be displayed at a time when there are hundreds of pages.

Tags:  Razor Page PaginationPagination


Search