Click here to Skip to main content
15,904,653 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

I have a windows forms application which is event based. So when the form loads up, I have to launch a web page (login page) and use the configured User Id and Password to login to the web site.

When an even occurs in the application, I will then launch the appropriate URL's, which will bring the pages specific to the user.

The main hurdle for me is the first part. Can some one help me with how I should proceed on achieving that?

I am very new to the web related part of the programming. Any replies with code snippets will be appreciated.

Thanks in advance,
-Bhaskar
Posted

1 solution

The below code will open the default browser and navigate to the website.
C#
string target= "http://www.google.com";

try
{
    System.Diagnostics.Process.Start(target);
}
catch(System.ComponentModel.Win32Exception noBrowser)
{
    if (noBrowser.ErrorCode==-2147467259)
        MessageBox.Show(noBrowser.Message);
}
catch (System.Exception other)
{
    MessageBox.Show(other.Message);
}


Also, do you want to pass the credentials? You can pass them as encrypted parameters in the query string or you can also use cookies.
 
Share this answer
 
v2
Comments
bhaskar82in 8-Mar-11 5:41am    
Hi Ryan,

Thanks for your reply. The code snippet you provided will help me launch a browser with the web page only. The main challenge I am facing is to pass the credentials to the web page and validate them in case of incorrect password/login id.

Thanks for your help.
-Bhaskar
Ryan Zahra 8-Mar-11 5:44am    
Write a cookie: http://msdn.microsoft.com/en-us/library/aa287547(v=VS.71).aspx
Read a cookie: http://msdn.microsoft.com/en-us/library/aa287533(v=VS.71).aspx

Before launching the webpage, create the cookies.
When the webpage is being loaded, search for the cookies.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900