Getting CORS error in Angular 8 while trying to post data to Asp.net core web api

I am making CRUD using Angular 8 and Asp.net core. Everything works fine until I submit data. It returns me following error. Access to XMLHttpRequest at ‘http://localhost:56975/api/PaymentDetail‘ from origin ‘http://localhost:4200‘ has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response. I already add Microsoft.AspNetCore.Cors package. This is…

How to write custom console command for ASP.NET MVC application? To execute like “dotnet run my-custom-command arg1 arg2”

I’m trying to find information over the internet, but everything around points just to dotnet cli utility. It seems nobody or almost nobody asked for feature to have ability to run console command from MVC app. My reasons to have it: I have MVC app and I want to create custom console commands to: –…

C# asp.net core 2.2 – Get current date time – Not Accurate

I tried everything to get the current year/month/date/hour but It doesn’t work. I always get data 1 hour behind. So if it’s 17:00 in the Netherlands, I get 16:00. I have tried so many things, but I can’t get this fixed.. is it a bug? I Tried this: string dateTimeNowPlusForecaseHour = DateTimeOffset.Now.ToLocalTime().AddHours(hour).ToString(“yyyyMMddhh”); And this: string…

ASP.Net Core 2.2 – separate serializer settings for input and output

ASP.Net Core 2.2 allows to set serializer settings using MvcJsonOptions.SerializerSettings property. The problem is that it affects both input and output. Is there a way to have separate options for input (deserialization) and output (serialization)? In particular, I need to set a different behavior for NullValueHandling settings: ignore null errors for non-nullable fields when deserializing…

How to make code execute automatically every minute in asp.net mvc5 my websites

I have this code I have done using the application console and I want to use it inside my website using asp.net mvc5 in order to store the data it brings from the RSS feeds and store it in a database using System; using System.Collections.Generic; using System.Linq; using System.Xml; using System.Xml.Linq; using System.Text; using System.Threading.Tasks;…