Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Getting the URL and IP address of the client connection #1114

Closed
nrhoffmann opened this issue Nov 13, 2017 · 9 comments
Closed

Getting the URL and IP address of the client connection #1114

nrhoffmann opened this issue Nov 13, 2017 · 9 comments

Comments

@nrhoffmann
Copy link

How you get the URL and IP address of the client connection?

Also, is there any form of documentation on the new core version of SignalR? That I could consult instead of opening issues on your Github?

@analogrelay
Copy link
Contributor

analogrelay commented Nov 13, 2017

For the IP address, you can use the GetHttpContext extension method on ConnectionContext to get an HttpContext and then use the Connection property on there to find the client information.

For URL, do you mean the URL on the server that the client requested? The Client doesn't have a "URL" associated with it because it initiated the connection. The server URL is also available via the HttpContext.

As for docs, there's nothing right now. The code and GitHub issues are the documentation :).

@analogrelay
Copy link
Contributor

#944 added better support for getting Client IP data, and the rest is all available off the HttpContext via the ConnectionContext.GetHttpContext method. Closing this as I think that's covered the cases you asked about. Feel free to comment/reopen if I missed something!

@lblima
Copy link

lblima commented Oct 17, 2018

Hi guys, I still don't know how to get the url client called the hub. Is there any way to get this information? All I have is the hub path or client IP.

@analogrelay
Copy link
Contributor

analogrelay commented Oct 17, 2018

You want to know the URL of the Hub from within the hub? This isn't something we expose since there are numerous HTTP requests to different URLs as part of a SignalR connection.

@lblima
Copy link

lblima commented Oct 17, 2018 via email

@analogrelay
Copy link
Contributor

analogrelay commented Oct 17, 2018

I would like to know the caller URL.

What do you mean by "caller URL"? There is no URL for the caller, only an IP address. Can you describe what you want to use this information for? That would help me understand your scenario better.

@lblima
Copy link

lblima commented Oct 17, 2018 via email

@analogrelay
Copy link
Contributor

I see. That's not something we plan to support directly in ASP.NET Core SignalR since there's no guarantee the client is on a page at all.

You should be able to access the HttpContext through Context.GetHttpContext() though, and that should have the Referrer if you want to get that.

@lblima
Copy link

lblima commented Oct 17, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants