Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8430457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:35:52+00:00 2026-06-10T05:35:52+00:00

I have a MVC 3, VB.NET, Razor app that uses SignalR for a chat

  • 0

I have a MVC 3, VB.NET, Razor app that uses SignalR for a chat and system message system… The chat works flawlessly but I would like to be able to add a function in my admin controller that will send messages to the hub which the hub will then do its normal thing as if the Javascript had called it from a view…The hub is set up as below:

Imports SignalR.Hubs
Imports SignalR

Namespace SingalRTest
 Public Class Chat
    Inherits Hub
    Public Sub Send(ByVal clientName As String, ByVal message As String)
        'Call the addMessage method on all clients.
        Clients.addMessage(clientName, message)
    End Sub

 End Class
End Namespace

I thought about simply using NEW but that wont work because as I understand it the instance of the hub has to remain intact..

What i am trying to do is something like this:

 Public Function notification(ByVal systemMessage as string)
        Dim y As SingalRTest.Chat = Nothing
        y.Send(User.Identity.Name.ToString, systemMessage)
        Return RedirectToAction("Index", "Admin")
 End Function

This will not work at all and errors saying:

  Object reference not set to an instance of an Object

when it gets to the y.Send line…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:35:54+00:00Added an answer on June 10, 2026 at 5:35 am

    Wow, this took a lot of digging to find on the internet. I simply needed to add a shared sub in my Hub class which now looks like this:

    Imports SignalR.Hubs
    Imports SignalR
    
    Namespace SingalRTest
    
    Public Class Chat
        Inherits Hub
        Public Sub Send(ByVal clientName As String, ByVal message As String)
            'Call the addMessage method on all clients.
            Clients.addMessage(clientName, message)
        End Sub
        Friend Shared Sub SendMessage(message As String)
            Dim context As IHubContext = GlobalHost.ConnectionManager.GetHubContext(Of Chat)()
            context.Clients.addMessage("System Message", message)
        End Sub
    End Class
    
    End Namespace
    

    Then anytime I want to send a notification in the window, I would just drop this code in the controller function to call the addMessage method on all clients:

        SingalRTest.Chat.SendMessage("Testing Only")
    

    Maybe this will help someone else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp.net mvc application, that uses razor view engine. I want to send
I have a ASP.Net MVC app with Razor. I try to access a collection
MVC 3 VB.NET razor. I have a view that has 4 dropdown boxes in
I have a MVC 3.0 .Net 4.0 Razor application that is periodically giving me
I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that
In my ASP.net MVC App (using Razor views) I have a ProductDetails view. This
I just upgraded an ASP.NET MVC app to version 3.0 and Razor. I have
I am developing an ASP.Net MVC 3 Web application using Razor Views. I have
I have a VS 2008, .NET 3.5 targeted MVC.NET app. I am developing on
I am working on asp.net MVC 3 application. I have created a Razor view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.