如何将数据从Windows应用程序传递到Web应用程序?

我有一个Windows应用程序,我想从这个Windows应用程序打开我的Web应用程序。 我的Windows应用程序将在授权后生成密钥和机器代码,并将密钥和机器代码保存到活动用户之间的数据库中。 现在我想将此密钥发送到浏览器,以便我的Web应用程序可以使用他的机器识别用户。
我怎样才能做到这一点?
我无法使用URL,因为用户可以复制URL并从另一台计算机上使用我的Web应用程序。 我必须限制它。
还有别的办法吗?

有两种方法可以将winform数据传输到Web应用程序

如果要将数据传输到IE,则可以使用

1)MSHTML.DLL

InternetExplorer TargetIE = null; IHTMLDocument2 document = null; //Check whether the IE is opened foreach (InternetExplorer internetExplorer in new ShellWindows()) { if (internetExplorer.Document is HTMLDocument) { TargetIE = internetExplorer; break; } } 

2)如果您想将数据从winform传输到任何网络浏览器,我个人建议您使用selenium。 从此站点帮助下载相应驱动程序的相应DLL和驱动程序

 using OpenQA.Selenium; using OpenQA.Selenium.IE; using OpenQA.Selenium.Support.UI; using OpenQA.Selenium.Chrome; namespace WindowsFormsChrome { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // download the chrome driver IWebDriver driver = new ChromeDriver(@"C:\Users\Downloads\chromedriver"); driver.Navigate().GoToUrl("http://www.yahoo.com"); IWebElement myField = driver.FindElement(By.Id("txtUserName")); myField.SendKeys("UserName"); IWebElement myField = driver.FindElement(By.Id("txtPassword")); myField.SendKeys("Password"); IWebElement myField = driver.FindElement(By.Id("btnLogin")); myField.click() } } } 

这第二部分适用于所有浏览器,您只需根据需要替换chromeDriver类。

你可以使用c#发布数据

http://msdn.microsoft.com/en-us/library/debx8sh9(v=vs.110).aspx

另请参阅stackoverflow中的这篇文章

如何将数据发布到网站

您可以编写一个ashx处理程序,并从您的Windows应用程序传递您的数据(或对您的数据的一些引用)。 以下是如何完成此操作的示例:

如何调用ASHX处理程序并返回结果