Posts

Resolving the "An error occurred while accessing the Microsoft.Extensions.Hosting services" in ASP.NET Core

Introduction: When working with ASP.NET Core, you may encounter an error message stating "An error occurred while accessing the Microsoft.Extensions.Hosting services." This error often occurs when there are issues with service registration or configuration. One specific error scenario that can lead to this message is related to the use of the `AddDistributedSession` method in the `IServiceCollection`. This blog post will guide you through the process of resolving this error and configuring session options using the correct method, `AddSession`. Step 1: Understanding the error message The error message "An error occurred while accessing the Microsoft.Extensions.Hosting services" indicates that there are problems with the services being constructed and resolved within the ASP.NET Core application. In this case, the error is related to the session configuration. Step 2: Identifying the issue The specific error message you encountered includes the following information:...

Enable CORS: Angular & .Net Core API with Free Hosting Angular

Image
Enable CORS in Angular and ASP.Net Core API   In this blog post, we will explore how to enable Cross-Origin Resource Sharing (CORS) between an Angular application and an ASP.NET Core API. We will provide a detailed, step-by-step guide on how to configure CORS in both the Angular and ASP.NET Core API sides. CORS is a security feature that restricts web applications from making requests to servers that are outside of their domain. By enabling CORS, you can allow your Angular application to make requests to an ASP.NET Core API that is hosted on a different domain. To enable CORS in our Angular application, we will use the HttpClient module to send HTTP requests with appropriate headers. In our ASP.NET Core API, we will configure the CORS middleware to accept requests from the Angular application domain. By the end of this blog post, you will have a clear understanding of how to enable CORS in Angular and ASP.NET Core API. You will also have the knowledge to configure CORS for your ow...