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


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



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;

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


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

        private void Form1_Load(object sender, EventArgs e)
            // download the chrome driver
            IWebDriver driver = new ChromeDriver(@"C:\Users\Downloads\chromedriver"); 
            IWebElement myField = driver.FindElement(By.Id("txtUserName"));
            IWebElement myField = driver.FindElement(By.Id("txtPassword"));
            IWebElement myField = driver.FindElement(By.Id("btnLogin"));

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