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

  • SEARCH
  • Home
  • 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 8464237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:40:58+00:00 2026-06-10T14:40:58+00:00

This question is related to another thread, you can read here: Forms authentication with

  • 0

This question is related to another thread, you can read here: Forms authentication with SignalR where I tried with the help and patience of the user dfowler to understand how enforce forms ASP .NET Forms Authentication on a SignalR Hub.

Description of the problem: I want that only authenticated users can connect the SignalR Hub and receive/send messages.

Intrusion scenario: the intruder can potentially capture/access the HTML and Javascripts of the web page accessing the temporary files on a client computer. This intruder can therefore know all the details (methods, hub names etc) required to set up/use a connection to the Hub.
A proposed solution from dfowler is implementing IConnect:

You would implement IConnected and write the following code in Connect if(!Context.User.Identity.IsAuthenticated) throw new Exception(“GTFO”);

Therefore I tried with something like this

  public System.Threading.Tasks.Task Connect()
    {
        if (!Context.User.Identity.IsAuthenticated
            || !(Context.User.IsInRole("role1") || Context.User.IsInRole("role2")
            ))
            throw new Exception("User not authorized");
        return null;
    }

The problem, once tested, is that when the Connect method is being called, the connection has been already established and plain throwing the exception will not help (if I got if properly infact Connect should be used to send a message to the client at connection, throwing an exception will just yield in a welcome message not sent).

In facts, from my tests, the clients can still read all the messages (and also send them).

Now, approaches which come to my mind:

  1. Perfect solution: reject or terminate the connection on server side: no clue how to do this in SignalR (I tried to find a method in the API but no luck)
  2. check if the user is part of a group to avoid receiving/sending messages to him (but this is still prone to flooding/DOS attacks)
  3. Sending a message to the client to disconnect: obviously does not help in case I am fighting an intruder.

Any other approach? Any way to terminate the connection on server side or should be accepted that the only real authentication is the one of the host webpage (leaving open the door to all the signalR client attacks?)

EDIT

Here is the sequence of client – server communication when I use the IConnect.Connect method throwing unconditionally an exception (browser IE9):

client-server communication when Connect throws exception

It looks like the foreverFrame fails but the longPolling fallback is being established and works anyway – this after throwing the error captured in the Javascript by the block

 if (connection.state === signalR.connectionState.connecting) {
            // Connection hasn't been started yet
            throw "SignalR: Connection has not been fully initialized. 
    Use .start().done() or .start().fail() to run logic after 
    the connection has started.";
        }
  • 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-10T14:40:59+00:00Added an answer on June 10, 2026 at 2:40 pm

    We have an issue where we need to allow blocking the connection altogether. Right now you’ll have to guard each method. It’s not the cleanest but for 1.0 alpha1 we’ll have some mechanism for doing this.

    One additional problem is that it’s the same connection for all hubs so you can’t reject a connection for a specific hub.

    EDIT

    Actually if you throw it does end the connection as far as my testing goes. What behavior are you seeing?

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

Sidebar

Related Questions

This is closely related to another question: How can I measure thread stack depth?
This question is related to another question of mine. Thanks to some help I
I have asked another question related to this in this thread Where to put
This question is related to another: Will having multiple filegroups help speed up my
I've asked another related question to this here: casting dynamic to static problem I've
This question is related to another question I wrote: Trouble using DOTNET from PHP.
This question is related to another question, where I wanted to define a custom
This question is related to another question I asked Basically, I have 2 horizontally
This question is related to another question I just posted . I'm prepping for
This question is kind of related to another question but I have a specific

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.