I would like to implement SignalR into one of my WPF applications for its real-time capabilities to communicate between client and server. However, everything I have read points to SignalR only being used on web browsers. Would it be possible to use SignalR in my application that does not include any web browsers (without adding a WebBrowser element to my project displays)? To try to clarify, I would like to use all the perks of SignalR such that a couple displays in my application update their data in real time, with no web browsers. If so, what would this look like? Thanks!
Yes, SignalR has .NET, Java, and JavaScript clients. A web browser isn't necessary. Technically anything that knows one of the transport protocols that SignalR provides (such as web sockets) could have a client written for it.
Related
I am trying to figure out if ASP.net on the client side in order to support SignalR. I would rather not be reliant on asp.net if at all possible for the webclient. I haven't found anything thus far that leads me to believe that it is required, but I could be overlooking something obvious.
EDIT:
As noted by the comments my question was not correct. I am ultimately trying to find out if ASP.net is required to use SignalR. From Lain's comments below it doesn't sound like it is which is excellent!
Any information would be greatly appreciated.
No. ASP.Net isn't required on either the client or the server side.
ASP.Net is a server-side platform for .Net, so can't be used as part of a client.
There is a native C# / .Net client, but this is lightweight and does not require any http server platforms.
The server side or 'Hub' can be process self-hosted, or hooked into an existing IIS site. It does not use ASP.net directly, but can work side-by-side with an ASP.Net website.
You will need a hub running to connect to for your client.
For more information, see the SignalR project site, which has examples:
http://signalr.net/
SignalR is a libbrary build for asp.net that employs features like web sockets, long polling, forever frames. If you want to distant your self from asp.net you could implement any of these features with any server side language (directly not through signalR).
But for specifically using signalR without asp.net (although may be doable) is something I would prefer not to try or suggest. All that for the server side.
For client side simple javascript would suffice, so you do not need to use any microsoft technology there.
No ASP.NET is required for SignalR.
You'll need to have a class that Implements IHub and that class has to be in C# or VB which is obviously a language of .Net framework.
Also, the hub javascript file is outputted by signalr using c#
And any framework will be proud to announce itself platform agnostic, and signalr's home page's title itself mentions ASP.NET SignalR So defenitely you are going to need .Net.
And you need to have this RouteTable.Routes.MapConnection<MyConnection>(...); which is obviously c# in Global.asax, which is obviously executed only by a asp.net website.
And last but not the least, SignalR is implemented in C# and you need ASP.Net so that signalr executes c# in runtime.
That's a lot of reason, why you should definitely have asp.net :)
I've got a client who requires a secure transaction made over HTTPS. They do not provide any web services to consume, so instead they have a simple post over HTTPS with SSL. I have two applications that need to utilize this service, one is a website, one is an iOS app, so I figured to save some time and effort, I would write a proxy web service that both of these applications would use to pass data back and forth between the client's system.
So I have the web service sitting on a server, with an exposed web method which is being consumed by the application. The variables are in the method, can someone please help me with sending that data via https POST to the required URL? I've never done anything like this before and I'm a bit lost. The web service is programmed in C#.
If you are using .NET 4.5, you can use the System.Net.Http.HttpClient
http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx
or, System.Net.HttpWebRequest if you are using older version of the framework.
Here's an example
HttpWebRequest with https in C#
I want my web app (running in a browser) to, at some point, communicate (bidirectionally) with a desktop app (in Windows), the client has installed in its computer.
What's an elegant and modular and simple way of doing this (with Java and C#)?
Not much information will be passed between the web app and the desktop app. Just something like "I was here", "Pick this from this point", etc.
I solved that problem by using a database on the network.
All communications where made trough the database.
Website -> DB -> User logged in <- DB <- Desktop
However, if no trusted information needs to be shared, you could consider just posting and reading some http headers to a common website, or a simple log file.
Greetings
I suggest you to use the backend part of your webapp, assuming that your app is based on some backend services.
You have two options:
Your desktop apps use the same services of your web app. You must use a class that mimic a web-browser to give the data (curl, ie). If your web app is based on AJAX push ( APE Server i.e ) use library that is able to run some javascript
Use a REST protocol, with a JSON format in your backend services. It's easy to manage and is supported by many client-side languages (java/c#/python....)
Use a specialized endpoint only for your desktop app,for C#, you can use WCF, that allow you, in one of his forms bidirectional communications. For JAVA, there are WSDL, DWR
My preferred solution is to decouple the web app in a front-end side and a backend side, that expose the services as REST that are used by the web app via AJAX.
If I need true bidirectional communication with other desktop app, I'll create a separate service / endpoint for it. (APE , WCF, ..)
I see several options to achieve part of what you are asking:
Besically you expose the relevant parts of your apps (web and desktop) via some sort of API and use that for the communication - for example DB and/or WCF (SOAP/REST/whatever).
BEWARE:
If you are after some sort of direct/interactive communication between both apps on the same computer then this won't be possible - at least not without some security related issues.
The browser executes your web app in a sandbox which doesn't allow for direct communication between the web app and the desktop... there are technologies which can help circumvent that (ActiveX, signed Java applets, some Flash technology called AIR etc.)... or you could host some webbrowser/control in your desktop app which in turn runs the web app... BUT basically I would recommend against using any such measures...
IF you really want to go this route then please describe your environment and goal with much more detail.
Background
I have a windows console app written in C# which needs UI. I started using WPF, but as I come from a web background, I want to use html, and some features of html5, including web sockets for real time communication with another application.
Initially, I'll use a web browser as the UI, though I may later host a web browser in the main app. This bit doesn't concern me at the moment.
After a lot of googling/reading, I'm going round in circles. It looks like WCF can be used to serve html, json based web services, and possibly web socket streams.
A lot of googled info relates to pre .NET 4.0 community projects. Even post 4.0 there are several NuGet packages which seem to me to overlap what is already in the framework. To a WCF noob, it's all a minefield.
So, what areas of .NET 4.0 WCF and the various open source projects should I be concentrating my efforts on.
Requirements
I require a lightweight self hosted web server. It cannot be IIS based, as users will not have it installed. The server (or servers) must:
Be able to server complete web pages, including html, linked images, css and js files. C# MiniHttpd does the job well, but is not based on http.sys. HttpListener seems to be the core of what I want, but I haven't found a complete web server project based on it.
[optionally] Be able to parse those pages through asp.net or razor
Be able to respond to web service call via json. This bit I have a working example using System.ServiceModel. Is this the right way to go?
Be able to work with the emerging Web Sockets standard. SuperWebSocket is actively developed, but doesn't appear to be http.sys or wcf based.
Preferences
I would prefer to stick to one basic stack for all 3 of my main requirements - and I suspect WCF may be that platform.
I would prefer an http.sys based approach for all three requirements, so I can reserve the relevant url/port/namespace combinations and prevent conflicts with other web servers or services
Although other SO questions may help with individual aspects of my requirements, I need advice on a more holistic approach.
Ok, answering my own question feels wrong, but...
I have since found a great CodeProject article that provides an easy to use self hosted web server for serving the html, css, js and images, and serves the json requests.
Developing Web 2.0 User Interface for Self Hosted WCF Services using HTML5, CSS3 and JQuery
I still have to settle on a WebSockets solution, but the above project is as close to what I need as is possible at the moment. It doesn't support rendering asp.net or razor, but these were my lowest priorities, as I'm happy to use only pure html and javascript for the front end.
I'll try to post more specific questions in the future :)
Except for your WebSocket support requirement, the OpenRasta framework currently supports what you describe. It definitely can run in http.sys and can be used for both creating REST services and as a web app platform. It also supports Razor and other view engines. The link page has a good comparison chart toward the middle that compares it with ASP.NET MVC & WCF.
In March 2014, a solution which fits my original requirements is ASP.NET Web Api. It can be self hosted, and can apparently be set up to serve html etc as well.
Is it possible to serve a web page from a self hosted web API in a windows service?
We are in process of re designing an old windows client server based application to web based application.
This application is built in C# using Remoting and WCF. On client side its Windows and WPF.
My Queries
What all concepts should be taken care when we make this application web based?
What design patterns should be followed for Web Based Architecture?
In WCF part we are using Net TCP Binding which can be easily migrated to HttpBinding, but I am more concern over Remoting, will it able to Serve the purpose, means can Remoting serve the purpose when Http calls are being made?
I would probably merge "remoting" with wcf and use httpbinding endpoint. font-end you could decide to use MVC pattern which will give you a better performance.
Sorry to answer your question with a question but: From an architecture or business point of view, why would you want to do this?
Your original application uses Remoting, which does not work over the Internet, therefore I am assuming that this is an internal application.
A web application would have the following tiers:
The presentation which runs on the browser
The Web Server which sends the pages to the browser
The application server which would host your WCF services
The database server
As you see the web application in the browser does not call the services directly (unless you use REST based services)