SignalR web client without ASP.NET? - signalr

Is it possible to write a WebSocket (SignalR) client without having to embed it in an ASP.NET application hosted on IIS (or other ASP.NET web server)?
For example if I have a Self Hosted SignalR Server with a custom Hub, is it possible (and if so, how) to call it from a "pure" Javascript web client?
In that case we don't have the <script src="~/signalr/hubs" type="text/javascript" /> part with the run-time generated "magic" scripts in the ~/signalr/hubs/ folder.

You do not need to have an asp.net application for SignalR to work. You can create a generic html page and still communicate with a SignalR server. You can even utilize silverlight, windows phone or other clients to communicate with a SignalR server, there are plenty that are currently supported and even more that are third party developed (like android, ios, node etc.).
When you say "pure" JavaScript client I'm assuming you mean no third party libraries like JQuery, in this case SignalR currently does not work without JQuery but a client that does not depend on JQuery is in the pipeline (https://github.com/SignalR/SignalR/issues/372).
You can create a Self Hosted server pull down the SignalR by using ASP.NET Owin.
Edit:
In order to use self hosted servers you will have to enable cross domain in your application. See the answer to: SignalR: Error during negotiation request: undefined

Related

How to make Secure service to service calls between ASP.Net website and agent

I have a ASP.Net WebAPI service that is used by my AngularJS front end and I am making use of Owin and bearer token.
Now there is a need that we need to install an agent on the few of the client machines (developed in .Net core mostly) that is able to connect to our application and make similar calls. I can create a separate controller for this need, but want to host it in the same website.
How can I create a secure connection between this agent and the ASP.Net server hosted on Azure?
Currently I am looking at generating a Token during the agent installation based on the client MAC address and giving it with each call, but I am checking if there are any better way to address this need.
Any help in this direction is welcome.
Regards
Kiran
It seems that you’d like to enable only valid “agents” that installed on the client machines to communicate with your server, if that is the case, Azure AD provides Native Application to Web API authentication scenario (a native application that runs on a phone, tablet, or PC needs to authenticate a user to get resources from a web API that is secured by Azure AD), you could refer to it.

How to access client side scanner from server and upload scanned image to server?

I have to create a web application in asp.net, that will be hosted on server and access client side scanner. The end users scan the images and scanned image is then uploaded to server. My web application is running successfully in single system. But when i hosted it in IIS and tried to access it from a client machine with a scanner attached to it, the application is not working.It is not able to access client side scanner.I am using WIA concept for scanning.
Can any one suggest a way to access client side scanner from server?
Directly its not possible, as its a security breach.
You can use piad third party library
like http://www.dynamsoft.com/blog/document-imaging/web-twain-webcam/how-to-scan-documents-from-an-asp-net-web-application/
http://twainx.sourceforge.net/
http://www.dosadi.com/eztwain3.htm
Or
Flash
Or Silverlight
I would preffer a user a control created in Silverlight for scanning purpose. This is your WIA concept. a gud place to start.
http://10rem.net/blog/2010/04/14/scanning-an-image-from-silverlight-4-using-wia-automation
This can also be achieved by using WCF, refer
http://www.codeproject.com/Articles/493333/Client-Side-Printing-Scanning-in-NET
Another way is write an Active-x control, but this solution will be limited to IEs.

SignalR in WCF service to update web site clients

Using SignalR, is it possible to update website clients from my WCF service if the service is not used by these clients directly?
I have a desktop application in .NET which has WCF service used internally using net.TCP protocol. This application changes one of the status fields in database table depending on certain user actions. I want to notify this change to end users who are accessing a different website hosted on the same web server.
I have tried one SignalR sample where notification works fine if it is sent from same website's host to its own client (stock ticker sample). But in my case, the message should go from WCF service to a website client.
IMO you should do an intermediate hop, for example having your website exposing an endpoint (you pick the technology) where you can post whenever you have a change to notify. Your WCF service would post there whenever there's a change, and the web app would process the post by broadcasting info to the target clients (can be all, or can be just some you filter with some logic behind the post). I use this pattern quite frequently, implementing it with HTTP POST. You would have no issues to implement the SignalR infrastructure in the web app, which is where your clients already connect to.

Call web services ONLY from client side

I have a web based application that uses lot of client side requests in various .asmx files.
I am wondering if I can use those web services only from client side and restrict the requests from other sources.
The reason for this is because I want to use those web services only from the current application and to restrict requests from other sources. For security reasons I could use soap authentication but since I requested the services from client side, I don't think the authentication it matters.
I'll appreciate any comments.
Thanks
The webservices are by definition public, publicly visible and available (unless they run on private network or standalone computer). I.e. anybody can access them. So, just deploying a webservice and hoping for the best is not a good approach.
And how do you intend to restrict other access?

Integrating Instant Messaging into an ASP.NET application

I was thinking about integrating some instant messaging function into an existing ASP.NET web application, e.g:
the web application can display the online-status of users (are they currently logged in with their IM client)
users can send messages from the web application to the IM client of other users
users can initiate a IM chat from the web application (without having to know the other user's IM identification beforehand)
Does anyone know about some existing libraries, sample applications or other resources that might help implementing such a feature?
Thanks a lot for sharing your knowledge.
You should try Jabber. Demo client avaiable here.
There is an architectural overview, the main concept looks like this:
(source: webta.net)
And some citation from the site:
1. Goal
Create an multi-service instant messaging AJAX-based web application with internal accounting.
2. Main problem
We need to connect to IM servers from HTTP client (browser).
HTTP is a stateless protocol. This means that, theoretically, each HTTP request is being proccessed by separate http daemon proccess.
Once request proccessed (data sent to client), server fogets about client.
All IM services protocols are stateful.
When client connects to IM server, socket connection being created and connection much remain open for succesfull communication.
There's a list on the ASP.net site.
http://www.asp.net/Community/Control-gallery/browse.aspx?category=54
You might want to look at the .net implementation of jabber:
http://code.google.com/p/jabber-net/

Resources