C# – How to pass data from windows application to web application

asp.netc++winforms

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?

Best Solution

There are Two Ways to transfer winform data to web applications

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

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) If you want to transfer data from winform to any web browser my personal advice to you please use selenium for this. download the respective dll and driver for respective drivers from this site help

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

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