开发者

httpwebrequest in .net cf not preauthenticating

开发者 https://www.devze.com 2023-01-23 07:16 出处:网络
I am using the httpwebrequest class in .net cf with crede开发者_如何学JAVAntials for digest authentication. I have set the Preauthenticate property to true. I understand that the first request will no

I am using the httpwebrequest class in .net cf with crede开发者_如何学JAVAntials for digest authentication. I have set the Preauthenticate property to true. I understand that the first request will not contain any authentication and subsequent requests will but this does not happen in .net cf.

However, this happens just fine in the full featured .NET framework.

Why is this api different?

If it is not possible to authenticate properly, can I force authenticating in some way by parsing and creating my own? If yes, how can I do this?

Thanks in advance for your advice!

Subbu


I finally did get an answer and thought it might be useful for others if I post it.

The behaviour of the .NET CF Httpwebrequest object is deceptively simple.

All I had to do is to make sure the AllowStreamBuffering property is set to true. This allows the data to be buffered properly in the object stream before it is sent over to the server. This also applies to subsequent requests made through the same object.

Deceptively simple :)

Also, in addition to the above issue, I was also facing timeout operations. .NET CF has another behaviour in terms of local variable scope. Once the response has been parsed from the server, always call the Close method of the Httpresponse object. This is not necessary in the full blown version of .NET. I guess this is understandable in terms of the way the GC behaves on memory constrained device.

0

精彩评论

暂无评论...
验证码 换一张
取 消