Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/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登录到HTTPS页面#_C#_Asp.net Mvc - Fatal编程技术网

C# 通过C登录到HTTPS页面#

C# 通过C登录到HTTPS页面#,c#,asp.net-mvc,C#,Asp.net Mvc,我在哪儿都找不到这个,所以我想知道你是否能帮忙。我正在尝试创建一个脚本,通过C#自动登录到HTTPS链接 所以本质上-我有一个URL,其中包含一个我需要每天运行的报告,但其背后是一个带有用户名/密码的HTTPS登录 我正在尝试用C#创建一个脚本,它在X时间运行,使用用户名/密码登录?有什么想法吗 会爱你很久的!:) 编辑:--- 现在,如果我想将*.txt文件自动保存到数据库中,该怎么办?WebClient和NetworkCredential应该为您解决这个问题,例如: 以下是我编写的一些示例代

我在哪儿都找不到这个,所以我想知道你是否能帮忙。我正在尝试创建一个脚本,通过C#自动登录到HTTPS链接

所以本质上-我有一个URL,其中包含一个我需要每天运行的报告,但其背后是一个带有用户名/密码的HTTPS登录

我正在尝试用C#创建一个脚本,它在X时间运行,使用用户名/密码登录?有什么想法吗

会爱你很久的!:)

编辑:---
现在,如果我想将*.txt文件自动保存到数据库中,该怎么办?

WebClient和NetworkCredential应该为您解决这个问题,例如:


以下是我编写的一些示例代码,用于登录网站发送短信:

private void sendMessage(SmsMessage message)
    {
        HttpWebRequest request;
        HttpWebResponse response;
        CookieContainer cookies;
        string url = "http://www.xyzwebsite.com/";

        try
        {
            request = (HttpWebRequest)WebRequest.Create(url);
            request.AllowAutoRedirect = true;
            request.CookieContainer = new CookieContainer();
            response = (HttpWebResponse)request.GetResponse();
            if (response.StatusCode == HttpStatusCode.OK)
            {
                cookies = request.CookieContainer;



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

                String postData = "emailfrom="+credentials.Username+"&npa="+message.DestinationPhoneNumber.Substring(0,3)+"&exchange="+message.DestinationPhoneNumber.Substring(3,3)+"&number="+message.DestinationPhoneNumber.Substring(6)+"&body="+HttpUtility.UrlEncode(message.MessageText)+"&submitted=1&submit=Send";
                byte[] data = System.Text.ASCIIEncoding.ASCII.GetBytes(postData);
                request.ContentLength = data.Length;
                Stream stream = request.GetRequestStream();
                stream.Write(data, 0, data.Length);

                request.CookieContainer = cookies;

                stream.Close();

                response = (HttpWebResponse)request.GetResponse();

                response.Close();
            }
            else
            {
                Console.WriteLine("Client was unable to connect!");
            }
        }
        catch (System.Exception e)
        {
            throw new SMSDeliveryException("Unable to deliver SMS message because " + e.Message, e);
        }
    }

你说的HTTPS登录是什么意思?HTTP基本格式?Http摘要auth?你们这些家伙真是太棒了!!!!!