Signalr not serialize correctly CustomNotificationData
See original GitHub issueI create a custom notification data
[Serializable]
public class NewMessage: NotificationData
{
public string Data { get; set; }
public bool IsRequired { get; set; }
public NewMessage()
{
}
public NewMessage(string data,bool isRequired)
{
Data = data;
IsRequired = isRequired;
}
}
I send it using the NotificationPublisher
var body = new NewMessage("test data with boolean", true);
NotificationPublisher.PublishAsync(notificationName, body, null, NotificationSeverity.Info, new List<Abp.UserIdentifier> { new Abp.UserIdentifier(tenantId, userId) }.ToArray())
but when I receive the message in signalR it comes in this form
{
"type": 1,
"target": "getNotification",
"arguments": [{
"tenantId": 1,
"userId": 2,
"state": 0,
"notification": {
"tenantId": 1,
"notificationName": "NewMessage",
"data": {
"type": "Project.RealTime.Notifications.NewMessage",
"properties": {}
},
"entityType": null,
"entityTypeName": null,
"entityId": null,
"severity": 0,
"creationTime": "2021-03-10T07:27:45.3992987-05:00",
"id": "dfdca5d9-fddf-4962-a8d1-c75fad6fc2b1"
},
"id": "057a5037-5e33-4f97-ab30-8dfcbac6921e"
}
]
}
i check the notification on db and has the field Data and IsRequired without problem
this app is using Abp 6.2.0 and Net core 5, and postgresql database but I have the same code in another app on abp 5.14.0 and does not have this problem
thanks for your help
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
SignalR not serializing/deserializing custom DataMember ...
One possible solution is to switch the serialization engine to Newtonsoft's JSON implementation, as suggested in @Aleksandr Albert's answer.
Read more >ASP.NET Core SignalR custom serialization
I want to transmit data between client and server and vice versa using a custom serializer, and not using the default JSON option....
Read more >Can't serialize poco class · Issue #64
I'm sening a POCO with a SignalR hub then, it gets sent to my subscribed client, but the data is lost. The data...
Read more >Real time notification system
Introduction. Notifications are used to inform users on specific events in the system. ASP.NET Boilerplate provides a pub/sub ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is caused by SignalR using
System.Text.Json
since ASP.NET Core 3.0.You can switch to
Newtonsoft.Json
:Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson
NuGet package.AddNewtonsoftJsonProtocol
method call to theAddSignalR
method call inStartup.ConfigureServices
:https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-5.0&tabs=dotnet#switch-to-newtonsoftjson
@acjh you are the best, that work’s for me thanks