简体   繁体   中英

Post Data From Windows Form to online ASP.net website

I have developed a website using ASP.net technology and put it on an online server. On the other hand, I developed a C# Windows Form Application, and I want the data in the Windows Form to be sent to the server(ASP.net website). Please guide me how to write the server and client application.

You essentially need to have something to write to and the asp.net app needs to be coded to read from said thing. Here are a couple of ideas that I have gone with in the past.

1) A simple idea is deploy a db like sql and set your asp.net site up to read data from this db in order to populate a page. Then use odbc, or another supported connection type, from your windows app to write to the db. This of course requires that the client machine, where the windows form app is running, is on the same network as the db and has the permission to write to it. Not a perfect solution in my opinion but definitely an option.

2) The better approach here is deploying apis that your client app can interact with. You can create a .net core mvc app that has a few apis that write to a db that functions as the back end for your asp.net app. As with example 1, your app.net app populates it's page from data from a db. However, rather than using a restrictive solution to connect, like odbc, you expose a API endpoint, such as https://site/controller/action that is called by the client app to get data or to post data. You can secure these endpoints using oAuth2. Your clients, be they windows form or mobile app, get data by calling an API, and write data by calling an API. This is the basis for modern cloud software and really is the better way.

Hope this helps. I'm happy to further the conversation or answer more questions if you have them. You can reach me here or on Twitter @NickCGamb, where I provide free help to everyone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM