© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•11mo ago•
5 replies
zos

How to save signalR chat messages to database

    public async Task SendChannelMessage(string channelId, string content, List<IFormFile> attachments = null)
    {
        var authorId = Context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
        var result = await messageRepository.CreateChannelMessageAsync(authorId, channelId, content, attachments);

        if (!result.Success)
        {
            await Clients.User(authorId).SendAsync("UploadError", result.Message);
            return;
        }

        await Clients.Group(channelId).SendAsync("ReceiveChannelMessage", content);
    }
    public async Task SendChannelMessage(string channelId, string content, List<IFormFile> attachments = null)
    {
        var authorId = Context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
        var result = await messageRepository.CreateChannelMessageAsync(authorId, channelId, content, attachments);

        if (!result.Success)
        {
            await Clients.User(authorId).SendAsync("UploadError", result.Message);
            return;
        }

        await Clients.Group(channelId).SendAsync("ReceiveChannelMessage", content);
    }


the method
CreateChannelMessageAsync
CreateChannelMessageAsync
just add the message to the database, but somehow when I call it from my FE project, it just skip through it. Any help is strongly appreciated!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Saving Messages withj SignalR
C#CC# / help
11mo ago
Help for a SignalR chat app database (sqlite)
C#CC# / help
5mo ago
✅ SignalR client to client communication (chat)
C#CC# / help
2y ago
✅ How to save to database with ISO format?
C#CC# / help
16mo ago