本文介绍了401使用HttpWebRequest进行POST时(是的,我使用了Credentials)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HttpWebRequest来下载XML,并将数据POST回WebService并在POST上获得401。

I'm using HttpWebRequest to pull down XML, and POST data back to a 'WebService' and getting a 401 on the POST.

创建请求时,我添加了凭据,现在尝试了凭据缓存并将PreAutenticate设置为True,仍然获得401! :(

When creating the requests I've added Credentials and now tried a credentials cache and setting PreAutenticate to True, still getting the 401! :(

观察路由器上的HTTP流量我设置get make一个未经身份验证的GET请求..它命中401然后进行经过身份验证的GET并被允许通过。当我看到POST时,我看到它点击了401 ......它甚至没有尝试经过验证的POST。

Watching the HTTP traffic on the router I set the get make an unauthenticated GET request.. it hits the 401 and then makes an authenticated GET and is allowed through. When I watch the POST I see it hit the 401... and it doesn't even try an authenticated POST.

这只是在手机上(WinMobile 6.1上的紧凑型框架3.5和2.0)。相同的.exe在任何台式机上都能正常工作。

This appears only on mobile phones (compact-framework 3.5 and 2.0 on WinMobile 6.1). The same .exe works perfectly on any desktop machines.

我缺少什么?请帮助!

推荐答案

尝试手动设置标题:

这篇关于401使用HttpWebRequest进行POST时(是的,我使用了Credentials)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:02