问题标签 [httpwebrequest]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
23567 浏览

c# - 如何将 CookieCollection 插入 CookieContainer?

在我得到 httpwebrequest 的响应后,我希望保存获得的 cookie,以便在另一个 httbwebrequest 中使用它们。但是,我需要将 CookieCollection 插入 CookieContainer。我怎么做?试图做:

但这不断出现错误:对象引用未设置为对象的实例。

0 投票
4 回答
10500 浏览

css - 内部与外部 CSS

内部与外部 CSS 的优缺点是什么,考虑速度、请求、缓存等。就我个人而言,我不确定动态页面上的内部 css 是否会缓存..?

0 投票
4 回答
193769 浏览

c# - 如何使用 WebRequest 访问使用 HTTPS 的 SSL 加密站点?

我正在编写一个从用户提供的 URL 读取内容的程序。我的问题出在这样的代码中:

如果提供的urlhttps://URL,这将是破坏性的。任何人都可以帮助我更改此代码,以便它可以与 SSL 加密内容一起使用。谢谢。

0 投票
1 回答
1016 浏览

c# - 3.5sp1 中的 HttpWebRequest 超时

我们有一个服务可以打开几个 HttpWebRequest。在我们将服务器升级到 .net 3.5sp1 之前,它在 3.0 下运行良好。现在我们在等待请求时超时。(我们已验证端点已启动并正在运行)。

有几件事让这很有趣。增加最大连接数将使其在超时发生之前运行更长时间。此外,一旦我们看到请求等待,如果我们打开 Fiddler,它们都会成功。这些请求通过 Timer 打开(每次调用 Elapsed 委托时都会产生一个新线程),所以我们可能会看到死锁,但代码库没有改变,我们在 3.0 下没有这个问题

我想我的问题是,有没有人有任何关于解决这个问题的提示?sp1 中的 HttpWebRequest 中是否有任何更改会导致我们看到这种行为?

0 投票
1 回答
918 浏览

.net - 停止异步 HttpWebRequest

我有一个应用程序使用 HttpWebRequest 异步向 Web 资源发出多个并发请求。尽管我已将 HttpWebRequest 实例的超时属性设置为 5 秒,但有时当异步调用 BeginGetRequestStream 时,获取流可能需要比这更长的时间,并且导致引用混乱。有没有办法限制它请求流的时间?此外,如果我得到流并决定我想通过从不实际调用 BeginGetResponse 完全放弃请求,那么该操作过程是否有任何后果?

0 投票
21 回答
435613 浏览

.net - 使用 HTTPWebrequest (multipart/form-data) 上传文件

是否有任何类、库或一些代码可以帮助我使用HTTPWebrequest上传文件?

编辑2:

我不想上传到 WebDAV 文件夹或类似的东西。我想模拟一个浏览器,就像您将您的头像上传到论坛或通过 Web 应用程序中的表单上传文件一样。上传到使用 multipart/form-data 的表单。

编辑:

WebClient 不能满足我的要求,所以我正在寻找HTTPWebrequest的解决方案。

0 投票
5 回答
2467 浏览

.net - 你调用的对象是空的

我看到以下异常。

System.NullReferenceException:对象引用未设置为对象的实例。在 System.Web.Util.StringUtil.memcpyimpl(Byte* src, Byte* dest, Int32 len) 在 System.Web.Util.StringUtil.UnsafeStringCopy(String src, Int32 srcIndex, Char[] dest, Int32 destIndex, Int32 len)在 System.Web.HttpWriter.Write(String s) 在 System.Web.HttpResponse.Write(String s)

我已经对我正在响应的上下文进行了以下检查。

任何人都可以暗示可能导致这种情况的原因吗?

0 投票
4 回答
6234 浏览

c# - C#:httpweb请求

我正在尝试设置 httpwebrequest 标头的referer参数的值,但它给出了错误-

我正在使用的函数(C#):

错误:

0 投票
3 回答
8132 浏览

.net - Asynchronous Webrequest best practices

What is the best practice for getting a webrequest asynchronously?

I want to download a page from the internet (doesn't matter what) and avoid blocking a thread as much as possible.

Previously I believed that it was enough to just use the 'BeginGetResponse' and 'EndGetResponse' pair. But on closer inspection I also see that there is the option of using 'BeginGetRequestStream'

[UPDATE] GetRequestStream is used for POST operations

And then to add to the confusion, Should I be using stream.BeginRead and EndRead?

[UPDATE] this article suggests it is even better to process the HttpResponse.GetResponseStream asynchronously using Stream.BeginRead

What a mess!

Can someone point me in the right direction?

What is the Best Practice?

0 投票
1 回答
176 浏览

asp.net - 使用 Gridview 和文件传输

我需要在运行时针对 GridView 中的事件生成 Excel 工作表ItemCommand_click并传输文件,然后将 GridView 与状态更改重新绑定。

当我们使用 File transfer 重定向响应时,如何更新 GridView?