将C#桌面应用程序连接到网站吗? [英] Connect C# desktop application to website?
本文介绍了将C#桌面应用程序连接到网站吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个程序,可以通过串行连接到GSM调制解调器,我需要通过SMS来获取数据
然后将这些数据发送到我的网站SQL数据库
我如何进行这些配置,我可以串行获取数据,但我不知道如何与网站连接?
i have a program that connect through serial to GSM Modem i need to get data by SMS
and then send these data to my website SQL database
how can i do these configurations i can get data serially but i don''t know how to connect with website ?
推荐答案
Web服务将是最简单的方法. Google的"C#Web服务",您将获得很多成功.
A web service would be the simplest approach. Google for "C# web service" and you''ll get lots of hits.
如果您一定要使用该网站(而不是Nishant正确提出的Web服务) ,您可以使用类System.Net.HttpWebRequest
来请求Web服务器并使用System.Net.HttpWebResponse
获得响应.
这是一个要知道的窍门:您确实需要通过编译时类型System.Net.WebRequest
使用System.Net.HttpWebRequest
.运行时类型由URL定义.例如,查看如何执行POST:
http://msdn.microsoft.com/en-us/library/debx8sh9.aspx [ ^ ].
—SA
If you''re bound to use the Web site (and not the Web Service as Nishant correctly proposed), you can use the classSystem.Net.HttpWebRequest
to request the Web server and get response usingSystem.Net.HttpWebResponse
.
Here is one trick to know: you really need to useSystem.Net.HttpWebRequest
via a compile-time typeSystem.Net.WebRequest
. Run-time type is defined by the URL. For example, see how to do POST:
http://msdn.microsoft.com/en-us/library/debx8sh9.aspx[^].
—SA
这篇关于将C#桌面应用程序连接到网站吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文