如何从Windows应用程序,Web应用程序传递数据? [英] How to pass data from windows application to web application?

查看:315
本文介绍了如何从Windows应用程序,Web应用程序传递数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows应用程序,我想打开此Windows应用程序我的Web应用程序。我的Windows应用程序会生成授权之后,一个关键和机器code和将保存键,机器code到数据库的活动用户中。现在,我想这个键发送给浏览器,以便我的Web应用程序能够识别他的机器用户。结果
我怎样才能做到这一点?结果
我不能使用URL,因为用户将能够复制网址并从另一台计算机使用我的Web应用程序。我必须限制它。结果
有没有其他办法?

I have a windows application and i want to open my web application from this windows application. My Windows application will generate a key and machine code after authorization and will save the key and machine code in to database among active users. Now i want to send this key to browser so that my web application can identify the user with his machine.
How can i do this?
i cannot use URL because the user will be able to copy the URL and use my web application from another machine. I must restrict it.
Is there any other way?

推荐答案

有两种方式来传输数据的WinForm对Web应用程序

There are Two Ways to transfer winform data to web applications

如果您想将数据传输到IE那么你可以使用

If you want to transfer the data to IE then You can Use

1)的Mshtml.dll

1)MSHtml.dll

code

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的我个人的意见传递到任何Web浏览器请您使用硒这一点。
下载本网站帮助各个驱动器相应的DLL和驱动程序

code

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()
        }
     }
}

第二部分工作,为所有的浏览器yoou只需更换chromeDriver类按你想要的。

this second part work for all browser yoou just replace chromeDriver class as per you want.

这篇关于如何从Windows应用程序,Web应用程序传递数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆