WebRequest代码未处理

时间:2011-08-22 23:19:04

标签: c#

我做错了什么,我正在尝试登录但没有任何事情发生。意思是,服务器上没有显示错误消息和登录尝试。

private void Form1_Load(object sender, EventArgs e)
        {

            string strURL = "http://admin.domain.com/home/index.html?site_login_submit=1&redirect=&username=zzzz&password=zzz";
            System.Net.WebRequest req = null;

            try
            {
                req = WebRequest.Create(strURL);
                req.Method = "POST";
                req.Headers.Add("referer", "http://www.domain.com/");
                req.Timeout = 5000;
                WebResponse reqWebResponse = req.GetResponse();
                reqWebResponse.Close();
                linkSubmit.Text = "http://www.domain.com";
            }
            catch (Exception eq)
            {
                string sErr = "Cannot connect : " + eq.Message;
                MessageBox.Show(sErr, strURL, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }


        }

0 个答案:

没有答案