HTTP 请求 (POST) 在 DLL 库中无法正常工作?

发布于 2024-08-07 08:04:07 字数 475 浏览 5 评论 0原文

我正在尝试在 DLL 库中使用 TweetSharp

当我在 DLL 库中执行以下代码时,响应返回无效 (417 Unknown):

var verify = FluentTwitter.CreateRequest()
    .AuthenticateWith("<HIDDEN>",
        "<HIDDEN>",
        "<HIDDEN>",
        "<HIDDEN>")
    .Statuses().Update("It works!");

var response = verify.Request();

当我在 Windows 应用程序中执行相同的代码时,响应返回正确。

是否有任何东西(配置)可以使用 DLL 库和 Windows 应用程序中的相同代码以不同方式处理 HTTP 请求(使用 POST)?

I'm trying to use TweetSharp in a DLL Library.

When I execute the following code in a DLL Library, the response returns invalid (417 Unknown):

var verify = FluentTwitter.CreateRequest()
    .AuthenticateWith("<HIDDEN>",
        "<HIDDEN>",
        "<HIDDEN>",
        "<HIDDEN>")
    .Statuses().Update("It works!");

var response = verify.Request();

When I execute the same code in a Windows Application, the response returns correctly.

Is there any thing (configuration) that could process HTTP Requests (using POST) differently using the same code in DLL Library and Windows Application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

零時差 2024-08-14 08:04:07

最有可能的是,该库已将“Expect100Continue”设置为 true。应将其设置为 false。

http://groups.google.com/group/twitter- api-announce/browse_thread/thread/7be3b64970874fdd

看起来这个库需要更新。大约 10 个月前,这一情况发生了变化。

所以代码应该是这样的......

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

most likely, the library has the "Expect100Continue" set to true. It should be set to false.

http://groups.google.com/group/twitter-api-announce/browse_thread/thread/7be3b64970874fdd

Looks as though this library needs to be updated. This was changed about 10 months ago.

So the code should something like this...

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(newURL);
 request.Method = "POST";
 request.ServicePoint.Expect100Continue = false;
 request.ContentType = "application/x-www-form-urlencoded";
吾家有女初长成 2024-08-14 08:04:07

TweetSharp 确实可以处理 Expect100Continue 问题,因此这里还有其他因素在起作用。您的政策文件是什么样的?如果您处于中等信任环境中,则需要通过修改策略来确保可以从 DLL 发送 HTTP 请求。

TweetSharp definitely handles the Expect100Continue issue, so something else is at play here. What does your policy file look like? You need to make sure you can send HTTP requests from DLLs if you're in a medium trust environment by modifying your policy.

子栖 2024-08-14 08:04:07

可能与当前登录的用户相关

尝试使用您的网站应用程序池用户登录并再次运行您的代码

Probably its current logged user related

Try to log with your website application pool user and run your code again

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文