从C#Windows应用程序登录到网站 [英] Logging in to a web site from C# Windows Application

查看:75
本文介绍了从C#Windows应用程序登录到网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个基于事件的Windows窗体应用程序.因此,在加载表单时,我必须启动一个网页(登录页面)并使用配置的用户ID和密码登录到该网站.

当应用程序中出现偶数时,我将启动适当的URL,这将带来特定于用户的页面.

对我而言,主要障碍是第一部分.有人可以帮助我实现该目标吗?

我对编程的Web相关部分非常陌生.带有代码段的任何答复将不胜感激.

预先感谢,
-Bhaskar

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

推荐答案

以下代码将打开默认浏览器并导航至网站.
The below code will open the default browser and navigate to the website.
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);
}



另外,您是否要通过凭据?您可以在查询字符串中将它们作为加密参数传递,也可以使用cookie.



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.


这篇关于从C#Windows应用程序登录到网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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