401 when POSTing using HttpWebRequest (yes I used Credentials)

一笑奈何 提交于 2019-12-07 11:30:06

问题


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

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

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.

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.

What am I missing? Please help!


回答1:


Try setting the header manually:

http://devproj20.blogspot.com/2008/02/assigning-basic-authorization-http.html



来源:https://stackoverflow.com/questions/179425/401-when-posting-using-httpwebrequest-yes-i-used-credentials

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!