I need to create a web page that gets data from an SQL database, and can run certain executables (that have already been written from previous projects).The code to retrieve data from SQL was written in C#, as it was used previously with ASP.NET. Is it possible to reuse all of this code the way it is with my current application (using Angular)?
How to set up the server side? I know I probably have to create a web server, and then use "get" and "post" requests from the client side, am I on the right track. Can JavaScript client side communicate with a C#-written server side?
Unequivocally yes, you can have a JavaScript frontend communicate with a C# backend. There are two primary MS provided technologies that can be used:
ASP.NET WebAPI
SignalR
And lots of 3rd party ones (like Nancy).
WebAPI is a simple HTTP server typically used to build RESTful backends. Given your description its probably what you want to use.
SignalR is a protocol for "push" applications (though it can be used for server invocations). If you don't need to call client-side code its a bit overkill.
On the client side, if using WebAPI or similar on the backend, you just do HTTP requests as you would against any standard API. For AngularJS that's done with the $http service, for Angular (2+) that's Http and for 4+ HttpClient.
Related
We have two applications, one called flexOS locally on "the server", and one called flexVisu remote on "the client". The first one is doing the job, collection data and such things.
Historically those two applications are able to communicate via TCP/IP sockets and a proprietary binary protocol.
Now we want to replace the client application flexVisu with a web page hosted on the IIS locally on the server. Every web browser on every device should be able to display these web page(s).
Firstly we experimented with an additional application (flexVisuWebServer) on the IIS side that basically hosted a web socket server and translated the json data from the client into binary data for the server and vice versa.
But this always requires a http connection and a wss connection to be open at the same time.
I don't know why, but I don't like the idea of using javascript on the client to handle all the data processing to display the server data.
I think that it would be much easier if I wrote an asp.Net c# application that handles the connection to "the server" via our proprietary TCP/IP protocol. That way no conversion of data between binary and json format must be done, and the web page itself can be also written in C#.
This approach much more resembles the current approach with flexVisu connecting directly to flexOS, the binary data is directly used to fill in Windows Forms controls.
What am I missing here?
Would the asp.Net application be able to connect to a tcp socket and use our own protocol?
[Edit: 2021-02-09 at 16:18 localtime]:
I managed to use our proprietary TCP/IP protocol to connect from the web server to the flexOS in the page_load of the asp.net web page.
So basically it should not be a problem to use the underlying library to read data directly from the flexOS.
OT: Should i post subsequent ASP.Net questions here too, or open some more questions?
We decided to follow this concept:
the webpage is using a websocket connection to our application flexVisuWebServer and this application uses our propietary TCP/IP protocoll to talk with flexOS.
So currently, I am working on migrate an old project that implemented WCF service and consume it through Silverlight client. This WCF service is using duplex polling method that Silverlight automatically understands and knows how to deal with it. Hence, a new HTML client will be replacing that Silverlight client.
After doing some research, I found some working solutions: using long polling web api or similar, adding support for WebSocket in the WCF through .NET WebSocket implementation, and using SignalR. So far, I am leaning more to SignalR due to the fact that I want to minimize the changes to the WCF as much as possible.
So if my understanding is correct, when using SignalR, it will create a Hub proxy that communicates between the service in the server and the client. Also, it will take care of the transport for the communication, in which it can use WebSocket by default and fall back to other protocols if WebSocket is not supported in the browser, and it can do so without the implementation of the protocol in the service.
My question is that if I want to use SignalR with my current WCF service, what would be the steps to make it work? The WCF service is a self-host that is running as Windows service on a server. Inside the WCF service, I have different end points for sub-services as well as the current end point to the Silverlight client. So far I was be able to add self host SignalR with the WCF service project and it is running, but I am not sure what would be the next step. Do I have to add a separate end point for the SignalR hub?
Another question is that do I need to make some modification to the duplex services to make it work with SignalR? Also, can the client project be separated from the SignalR within the WCF service project? And finally, compare between adding support for WebSocket within the WCF service and just implement SignalR, which one would have a better advantage in long term.
Thanks.
.Net 4.5 has introduced NetHttpbinding in WCF that uses websockets automatically for duplex message pattern and http for request reply message pattern.
More on Nethttpbinding here -
https://msdn.microsoft.com/en-us/library/hh674273(v=vs.110).aspx
I am looking for a end to end example for Breezejs library with .NET WebAPI but without using either oData or Breeze.NET (Breeze's server side component).
I have tried looking at the sample code but it doesnt seems to give an example which does that.
http://breeze.github.io/doc-samples/
All the server side samples either have oData or breeze.NET dependency.
From what I understand it is possible to use breeze.js purely in client side (and have your own server side webapi (restful)).
"BreezeJS really is a pure JavaScript technology. You do not need any Breeze on the server. The server need not use use any Microsoft technology: not IIS, not Web API, not Entity Framework, not SQL server."
Source - http://www.getbreezenow.com/spa-template
Any help?
Update:
I dont like the fact that the server is 'coupled' with the client for the metadata information. I understand this is how the breezejs functions.However and this is my personal opinion but its lot of work just to get the client side tool working with the server. This also adds traffice between server and the client. Anyway we decided to not to use breezejs because of the same overhead. (Not saying its not good for other scenarios)
I'm working on a Parse web app and have run into some problems using the backbone.js based client side javascript sdk. I noticed the way I have things set up, the client can view all of my source code by simply using the dev tools to view source files and can also run code against the database (within the limits of the ACL's I've set). I've started working on rebuilding the app in cloud code using the Express.js module Parse provides so that all of my code is stored server side, but I was wondering how those using client side frameworks get around this obvious problem.
That's the issue with client-side code. Assume any code you send to the client is hacked, broken, and tampered with.
With JavaScript, your best bet is to use either Cloud Code and send AJAX or streaming data calls to the server, retrieve the data from the server at runtime (not super secure, but would fool some people), or accept that your code is vulnerable.
I typically work with frameworks in the MVC format, so I only expose a limited subset of the actual model via a REST API. I use both a client-side framework and a server-side framework. Any thing sensitive goes on the server.
Is it possible to execute Javascript on server side and to get the result on a client ?
If it is possible, how can i make the request to the dedicated Javascript file from my client ?
In fact, i have created a mobile application with embeeded Javascript, (using Phonegap) but i would like to put all Javascript files on the server and make some requests to the server to get the result.
Thanks for your help
See You have to create a Web Service on the Server Side to enable the Client(Phonegap App) to make an Ajax request and fetch some data.
Earlier you could have written a web service using programming languages like PHP, .NET, Java, Ruby, Python etc. But NodeJS provides the flexibility of writing REST Based web services in Javascript itself.
You can learn about it here: http://appsonmob.com/nodejs-expressjs-mysql/