Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C提交HTML表单#_C#_Html_Httpwebrequest - Fatal编程技术网

C# 使用C提交HTML表单#

C# 使用C提交HTML表单#,c#,html,httpwebrequest,C#,Html,Httpwebrequest,我正在尝试使用以下网页中的代码通过C#提交HTML表单: 我无法进入该页面。这是因为它使用javascript登录吗 private String readHtmlPage(string url) { String email = "email"; String password = "password"; String result = ""; String strPost = "email=" + email + "

我正在尝试使用以下网页中的代码通过C#提交HTML表单:


我无法进入该页面。这是因为它使用javascript登录吗

private String readHtmlPage(string url)
    {
        String email = "email";
        String password = "password";

        String result = "";
        String strPost = "email=" + email + "&password=" + password; 
        StreamWriter myWriter = null;

        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
        objRequest.Method = "POST";
        objRequest.ContentLength = strPost.Length;
        objRequest.ContentType = "application/x-www-form-urlencoded";

        try
        {
            myWriter = new StreamWriter(objRequest.GetRequestStream());
            myWriter.Write(strPost);
        }
        catch (Exception e)
        {
            return e.Message;
        }
        finally
        {
            myWriter.Close();
        }

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
        using (StreamReader sr =
           new StreamReader(objResponse.GetResponseStream()))
        {
            result = sr.ReadToEnd();

            // Close and clean up the StreamReader
            sr.Close();
        }
        return result;
    }

你收到了什么回复?很可能该页面需要cookie才能登录“这是因为它使用javascript登录吗?”您正在询问谁。使用Fiddler并比较请求及其响应。当我执行代码时,我会得到相同的页面,即,我无法输入我的帐户,因为看起来我什么都没做。如果页面需要cookie登录,我应该怎么做?