Hello, we have an application using ASP.NET CORE MVC & jQuery. It is hosted on Azure AppService (Windows), and also the database is on Azure. Recently we updated from dotnet 6 to dotnet 8, with your version 13.2.0 . After we pushed the update to Azure, the application is crashing after ca. 2 days. We have to restart the Application to get it running again. From the log we can see that it cannot connect to the Host database when the issue occurs.
ERROR 2024-08-28 19:09:41,023 [19 ] .EntityFrameworkCore.Database.Connection - An error occurred using the connection to database 'Host' on server 'xxx'. WARN 2024-08-28 19:09:41,041 [19 ] Abp.BackgroundJobs.BackgroundJobManager - System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at Microsoft.Data.Common.ADP.ExceptionWithStackTrace(Exception e)
In the forum we found other people having same or similar problems: https://support.aspnetzero.com/QA/Questions/12096/API-Application-Crashing-Randomly https://support.aspnetzero.com/QA/Questions/12003/Site-stopped-working-after-every-1-2-days As considered in these similar issues, we already checked if all our Abp Nuget Packages are > 6.4, they are on version 9.2.2 in all projects in the solution.
Hi, I have an application build with AspnetCore + JQuery.
I want to hide a menu item if a tenant has a certain feature activated. In other words, I want to show one menu item if the feature is activated, but show another menu item if the feature is not activated.
In AppNavigationProvicer.cs I can add Menuitems with "featureDependency". If the feature is activated, the menu item is shown, otherwise not. But I want also the opposite. Is that possible?
Solution: Angular + Asp.Net Core Version: 13.1.1
Issue: After upgrading from version 12.2.1 to Version 13.1.1 submitting a datetime value as UTC does not work correctly.
After you upgraded to .Net 8 , you also removed .AddNewtonsoftJson() from Startup.cs
What I do is submitting data that contains a date value explicit as UTC, here an example of Json data we want to submit:
{
"id": 3133,
"name": "Test mission",
...
"date": "2024-05-10T00:00:00.000Z",
...
}
As you can see, the "date" value is formatted as UTC.
The c# Type of "date" is DateTime:
public DateTime Date { get; set; }
When submitting the data to the api, the date kind is now not Utc but local. I tested this:
without .AddNewtonsoftJson() in Startup.cs
var test = input.Date.Kind; // => local
but with .AddNewtonsoftJson() in Startup.cs
var test = input.Date.Kind; // => Utc
I did a simple additional test in the same CreateOrUpdate method (without .AddNewtonsoftJson() in Startup.cs)
var testDate = System.Text.Json.JsonSerializer.Deserialize<DateTime>("\"2024-05-14T00:00:00.000Z\"");
var testKind = testDate.Kind; // => Utc
From this simple test I can see that System.Text.Json can understand that this is intended as Utc date, but why is it not with the date I am sending to the api?
The problem with the new setting is, that the data saved to the database does change the time part of the date. In my case it has a value of +2 hours : 2024-05-14 02:00:00.0000000
All suggestions about this I found was to implement a custom JsonConverter for Datetime. I tried to implement one, but unfortunately it does never hit:
Converter:
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace custom.JsonConverters
{
public class JsonDateTimeConverter : JsonConverter<DateTime>
{
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return DateTime.Parse(reader.GetString()).ToUniversalTime();
}
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
{
writer.WriteStringValue(value.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"));
}
}
}
In Startup.cs :
mvcBuilder.AddJsonOptions(options =>
{
options.JsonSerializerOptions.Converters.Add(new JsonDateTimeConverter());
});
Do you have an idea what is wrong?