标签: webclient

如何在MVC网站上从Web用户获取屏幕截图/屏幕截图?

我见过几个不同的应用程序,允许用户在他们的PC上拍摄屏幕截图,然后该实用程序将自动将图像上传到Web服务器.我想将这种类型的功能合并到一个新的MVC站点中.

我当然可以让用户上传他们自己的图像,但如果他们可以点击Capture Screen Shot并且图像会自动上传,那就更干净了.

我的团队正在使用带有SQL后端数据库的ASP.NET MVC2.我们当然愿意考虑第三方组件(基于activeX等),这将使我们能够实现这一目标.

更新....

谷歌的做法与他们的报告类似.所以闻起来并不是闻所未闻......

asp.net-mvc jquery screenshot webclient

8
推荐指数
1
解决办法
7969
查看次数

来自Asp.net的WebClient给出"现有连接被远程主机强行关闭"错误

我想发布到我们的星号框来解析电话列表

从控制台应用程序这工作:

 class Program
  {
    static void Main(string[] args)
    {


        Console.WriteLine( HttpPost());
        System.Threading.Thread.Sleep(10000);
    }

    public static string HttpPost()
    {
        var URI = @"http://sip.ligmarine.com/admin/config.php?quietmode=on&type=tool&display=printextensions";
        var Parameters = "display=printextensions&quietmode=on&type=tool&core=core&featurecodeadmin=featurecodeadmin&paging=paging";
        var retVal = "";
        WebClient wc = new WebClient();

        wc.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes("maint:password")));
        wc.Headers.Add("referer", @"http://sip.ligmarine.com/admin/config.php?type=tool&display=printextensions");
        wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

        retVal = Convert.ToBase64String(Encoding.ASCII.GetBytes("maint:password"));
        //Console.Write("Resulting Request Headers: ");
        //Console.WriteLine(wc.Headers.ToString());
        byte[] byteArray = Encoding.ASCII.GetBytes(Parameters);
        //Console.WriteLine("Uploading to {0} ...", URI);
        // Upload the input string using the HTTP 1.0 POST method.
        byte[] responseArray = wc.UploadData(URI, "POST", byteArray);
       // …
Run Code Online (Sandbox Code Playgroud)

c# asp.net webclient

8
推荐指数
2
解决办法
4573
查看次数

webclient远程服务器返回错误:(500)内部服务器错误

我正在尝试使用webclient下载网页并获取500内部错误

public class AsyncWebClient
    {
        public string GetContent(string url)
        {
            return GetWebContent(url).Result.ToString();
        }
        private Task<string> GetWebContent(string url)
        {
            var wc = new WebClient();
            TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();

            wc.DownloadStringCompleted += (obj, args) =>
            {
                if (args.Cancelled == true)
                {
                    tcs.TrySetCanceled();
                    return;
                }

                if (!String.IsNullOrEmpty(args.Result))
                    tcs.TrySetResult(args.Result);
            };

            wc.DownloadStringAsync(new Uri(url));
            return tcs.Task;
        }
    }
Run Code Online (Sandbox Code Playgroud)

并致电:

var wc =new AsyncWebClient();
var html = wc.GetContent("http://truyen.vnsharing.net/");    >> always get the above error
Run Code Online (Sandbox Code Playgroud)

如果我使用其他网站,那么它的工作正常.不知道这个网站有什么特别之处.

请帮忙 !!

c# webclient httpwebrequest

8
推荐指数
1
解决办法
1万
查看次数

c#无头浏览器,支持crawler的javascript

任何人都可以建议支持cookie和authomatically javascript执行的无头浏览器吗?

.net c# webclient headless-browser

8
推荐指数
2
解决办法
1万
查看次数

WebClient.DownloadFileAsync真的这么慢吗?

我正在使用从服务器下载一些文件的DownloadFileAsync方法WebClient,我不禁注意到在VS2010中我的代码的非正式测试中,它在启动时会阻塞大约3秒钟,在我看来,首先打败了目的.

以下是相关的代码片段:

WebClient downloader = new WebClient();
downloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(updateDownloadProgress);
downloader.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(downloadCompleted);

var current_map = map_downloads[0];//string with filename, map_downloads is List<string>

var path = System.IO.Path.GetTempFileName();

downloaded_maps.Add(path);//adding the temp file to a List<string>

downloader.DownloadFileAsync(new Uri(MAP_BASE + current_map), path); //MAP_BASE is a string containing the base url
Run Code Online (Sandbox Code Playgroud)

DownloadFileAsync当应用程序下载~100 MB文件时,我正在使用UI阻止阻止.显然,如果UI在呼叫开始时阻塞了3秒,那么即使不完全,也会稍微减少效用.

我对C#/ .Net相对缺乏经验(大约3 - 4年前我做了一堆.Net 2.0的东西,IIRC,但我现在基本上重新学习它).

c# performance webclient downloadfileasync

7
推荐指数
3
解决办法
6308
查看次数

如何增加ASMX Web服务的POST大小?

背景

我正在开发一个ASP.Net服务器端控件,需要与ASMX Web服务进行通信.服务器端控件使用WebClient对象与Web服务进行通信,因为它需要经常在各种应用程序中重用,并且为了使开发人员更容易,他们不需要创建对Web服务的服务引用.

履行

在使用控件期间,需要将序列化对象发送到Web服务.使用the XmlSerializer对序列化对象,然后使用chilkat压缩库压缩生成的XML字符串.控件的Web服务调用如下所示:

webClient.UploadStringAsync(new Uri(serviceHost + serviceMethod), "POST", sendData)

sendData(string)的内容是compressedResponse={CompressedData}.

Web服务有一个定义如下的方法来接收数据,然后使用chilkat库解压缩字符串值,然后使用该序列对对象进行反序列化XmlSerializer.

public void SaveResponse(string compressedResponse)

控制和服务之间的通信正在进行.最初web.config,在上述任何一项中都没有定义任何设置或绑定.初步搜索后,我确实添加了

<httpRuntime maxRequestLength="20480"/>

客户端和服务器web.config文件.这没有任何区别.

问题

压缩或未压缩在sendData变量中发布到Web服务的数据对于正常的POST请求来说很大,并且已损坏.在以压缩格式将字符串发布到服务器之前和之后检查字符串的最后几个字符时,会确认这一点,并且在解压缩时,Xml文档在检入调试器时缺少最后一个根标记.在string无法解压缩,因此,服务调用失败每次.

如何增加WebClient请求的POST大小以确保服务器收到完整的字符串?

我已经查看了Google上的各种选项,但没有一个能够给我一个足够好的样本,可以在哪里进行更改,或者样本的变化需要看起来像.我完全不知道是否需要在服务器或消费网站上进行更改,并且因为没有为此定义绑定,如何在web.configASMX HTTP服务调用中创建绑定.

c# web-services webclient asmx http-post

7
推荐指数
2
解决办法
1万
查看次数

.NET WebClient.UploadValues与WebClient.UploadData

我正在编写一个类库,以便在我无法控制的站点上执行操作.该网站接受表格帖子作为输入.

谁能告诉我这两种方法之间是否存在差异,除了要上传的数据形式?

    System.Net.WebClient.UploadData(Uri, Byte[]);

    System.Net.WebClient.UploadValues(String, NameValueCollection);
Run Code Online (Sandbox Code Playgroud)

我不反对以任何方式安排数据,但开始想知道实际上有什么区别,并且它仍然以某种奇怪的方式唠叨我,不知道是否存在差异.

.net webclient

7
推荐指数
1
解决办法
3434
查看次数

如何从控制台应用程序将文件上载到ASP.NET MVC

我正在尝试使用控制台应用程序将XML文件发送到在ASP.NET MVC 3中开发的Web应用程序,并接收另一个XML作为响应.

控制台应用程序中返回的错误是:

远程服务器返回错误:(500)内部服务器错误.

当我让Fiddler2运行时,我看到了这个错误:

你调用的对象是空的.

控制台应用程序中的代码是:

static void Main(string[] args)
{
    var wc = new WebClient();
    byte[] response = wc.UploadFile("http://mysite.com/Tests/Test", "POST", "teste.xml");
    string s = System.Text.Encoding.ASCII.GetString(response);
    Console.WriteLine(s);
    Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)

MVC控制器中的代码是:

[HttpPost]
public ActionResult Test(HttpPostedFileBase file)
{
    XElement xml = XElement.Load(new System.IO.StreamReader(file.InputStream));
    var test = new MyTest();
    return File(test.RunTest(xml), "text/xml", "testresult.xml");
}
Run Code Online (Sandbox Code Playgroud)

RunTest()效果很好,因为这个方法在我通过表单上传文件时使用(在同名的方法中,使用方法GET).RunTest()返回带响应的XML.

当我调试MVC应用程序时,我看到了问题:变量file为null!

我该如何解决这个问题?我需要在我的控制台应用程序中更改它才能实际发送文件?或者是改变MVC方法的情况?

并且,在尝试使用之前WebClient,我在这里尝试了这个代码:http://msdn.microsoft.com/en-us/library/debx8sh9.aspx,并得到了相同的结果.

c# webclient file-upload console-application asp.net-mvc-3

7
推荐指数
1
解决办法
5614
查看次数

导入错误:无法导入名称“WebClient”

我做不到

from slack import WebClient
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

导入错误:无法导入名称“WebClient”

已安装 slack 模块

pip install slack
Run Code Online (Sandbox Code Playgroud)

错误:

回溯(最近一次调用):文件“E:\Downloads\slack-automation-master\channel_messages.py”,第 3 行,在 from slack import WebClient ImportError: cannot import name 'WebClient'

python api webclient slack

7
推荐指数
1
解决办法
8034
查看次数

dotnetcore 3.1 的 HttpClient 的 TLS1.2 添加密码套件

我在连接西部数据网站时遇到如下异常:

\n

西部数据网站

\n
22:02:34,803 |      HttpGrabber | DEBUG | Grabbing: GET https://shop.westerndigital.com/de-de/products/internal-drives/wd-red-sata-2-5-ssd#WDS200T1R0A\n22:02:34,858 |      HttpGrabber | DEBUG | System.Net.Http.SocketsHttpHandler.Http2Support: True\n22:02:34,865 |      HttpGrabber | DEBUG | System.Net.Http.UseSocketsHttpHandler: True\n22:02:35,067 |      HttpGrabber | ERROR | System.AggregateException: One or more errors occurred. (The SSL connection could not be established, see inner exception.)\n ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.\n ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.\n ---> System.ComponentModel.Win32Exception (0x80090326): Le message re\xc3\xa7u \xc3\xa9tait inattendu ou format\xc3\xa9 de fa\xc3\xa7on incorrecte.\n …
Run Code Online (Sandbox Code Playgroud)

c# ssl https webclient .net-core

7
推荐指数
2
解决办法
1万
查看次数