How do you send data from an ASP.NET web application to a windows form application?? How do you establish the connection? I looked up webrequest/webresponse/post but i think thats only if you want to communicate between 2 asp.net web applications.
You might use a socket.
It would help if you're more specific about exactly what you're trying to accomplish. Do you need live communication, or would connecting to a shared database do what you need? Is the web application on the same computer as the server or a different one from the forms application?
Update:
If you're trying to pass messages to the Windows Form without using or implementing any sort of protocol, you might look into how to use LISTEN/NOTIFY on PostgreSQL. You could then just add data to a table, then have the forms application consume the data. This would have the added benefit that your forms app wouldn't have to miss any data if it was not on.
My opinion to you is to implement a webservice. I made a project for mobile devices using webservices, the mobiles had an application made in winforms that call a webmethod that made an action which was registered in the system. A web page showed the data and the events of every mobile device.
If you need an explantation of webservices you can go here.
The strategy in your case would be to implement the Observer Pattern or to raise an event to make the application or winform to be noticed about a change or action in the web page.
Related
I want to make a pictionary like webapp.
I chose to develop using the .net platform, and decided to make a blazor client with a asp.net server, but I don't know how to communicate between them.
When a player is drawing something, as he/she draws, whatever he/she is drawing should appear on the other player's client, but I don't know how should to send this data to the server and back to the other clients.
I took a look at gRPC but don't know if this is the right tool for this kind of communication assuming a tickrate of 20 to 50 times a second.
You may create a Blazor WebAssembly App, which is running on the browser, and whose default means of transport is HTTP. However, you can use SignalR Client for your requirements. This is the way to go. Look up in the docs for the sample of creating a chat app in Blazor WebAssembly employing SignalR Client. There are also code samples created by the community demonstrating how to create advanced chat applications and games, and every thing involving that.
Good luck...
I'm going to build my own system include asp.net web site and web api, they are host on separate site. Architect diagram like image link below.
Every time client update something. I need to notify to the others. For example if client 1 upload a photo via web, then client 3 and (mobile app) and client 4(desktop app) should get a notification.
My problem is how to tell SignalR send notify to clients in this case. Please advice.
Your diagram must be changed in order to achieve what you need.
In order for this to work all the client types must be SignalR aware. For the web application it's straightforward since the "client" code is the website code itself.
For the mobile and desktop you have an extra layer (webapi) which in this case is an obstacle.
You should define a SignalR hub and connect to it from all the clients: WebApp, MobileApp, DesktopApp.
Knowing this, you can make a WebAPI project containing all the API methods and the SignalR hub(s) and connect to it from the other applications, website included.
As far as I know this is the only way to make this work, as you need to include SignalR library in all the clients code and use it to communicate with the hub(s).
How to work when internet connection down in a asp.net application ?
Means Users are working on application and suddenly internet connection down then user should still be able to add/edit/ delete operation on data, but when internet connection is up then
all changes should be done at server. Is that possible, Is there any example available to achieve this?
Thanks.
HTML5 has some offline capabilities. http://www.html5rocks.com/en/features/offline
But do you really have a business case for this? It will get complicated when you need to try and update stale data etc.
This requires use of JavaScript to store local data http://code.msdn.microsoft.com/Working-with-HTML5-local-b0cbe2ef and it needs to check whether the server can be reached before doing a proper postback, or more likely just use AJAX to communicate between the JavaScript application and the server.
There are several applications like this such as Google Mail, and such solutions are more JavaScript based than ASP.NET and you need to avoid relying on the web forms mechanisms and use .NET for building the initial page, dealing with AJAX requests and managing the application data and persistence. See How to write an offline version of an AJAX/ASP.NET web application
I'm new to web services. i'm developing a project that includes a website for introducing information (backoffice), and that information will be send to mobile devices.
My Question is, is better to create a website that connects to the database to insert and update information and then create a webservice only for the mobile devices to get that information, or create a webservice that does all the work?(website and mobile devices connected to webservices).
Thank you
There are many solutions and which you choose depends on how your application will be used.
In any case it is always good to have reusable code, and having single service tending to both web and mobile applications would be good.
If your application is write intensive, data which is passed between user and the website is critical and data integrity must be preserved, then you should go for a single service which runs in the background, takes care of integrity and provides data retrieval and modification methods to clients (web/mobile/desktop applications).
If your application is read intensive, will be mass deployed, with tens or hundreds of thousands of clients, then you should go for each web application which connects directly to database. In this case you need to sacrifice data consistency, because writes made on one node of the web application will not be instantly visible on others. Using this method, when you need to scale out you can add replicated database nodes, and new web application nodes that connect to them.
If you have a client application running on a mobile device, you want a web service. I recommend a RESTful one using JSON. If you want to access this functionality from a computer browser, you'll want a website - which could be accessed from a browser on a mobile device.
The trade-off is accessibility vs. quality of the client application. A website may work great from a computer browser, but may not be well-suited for mobile access. The website would be a single solution though. If you use a web service, you need a mobile application to consume it (presumably for multiple platforms), plus either a desktop application to consume that web service or a website to run in a browser...
In my opinion. You should go with Services Based Architecture. You can use WCF /Asp.net Webapi on MS Stack. Using Services either SOAP Based or REST gives you more Flexibility and a degree of scalability for the consumers to consume your service.
Hope this helps.
I have a c# window form application (which is basically a game).
And an ASP.NET Website. the window form application has a database with a table that contains the username and his cash. The asp.net database has a table that contains the username and his cash.
Now I want to sync between to the two servers. Once I get point in my game, It'll also update the database of the asp.net site.
You could expose a web service endpoint in the web app which the Windows app can call to post updated user stats.
Likewise a web service could return updated stats to the Windows client for synchronization into the Windows app database.
As Uwe Keim mentions, the web app can only expose a service or data feed that the Windows client must poll regularly. There is no feasible way that the web app can call the Windows app directly.
Why not host the database on one location and let the game/website connect to your DB through a web service? This way you only need one database with all the relevant data compared to two. You'll have to recode some parts of your website and game but in the long run this is more optimal than two databases with the same data.
More information regarding web services can be found here.
You can develop some kind of an API (Service) in the web application and do the sync between the two apps. You are talking about two servers at the end of your post. What kind of servers are you talking about? Is the game available in standalone also? If not, can't you think of having a single DB for both of them?