Sunday, August 16, 2009

WebRequest.AllowAutoRedirect Failure

The most recent release of PockeTwit has an annoying bug that causes the first request upon startup to fail with a communication error.  I finally tracked down the code to one line within our WebRequest factory:

public static HttpWebRequest CreateHttpRequest(Uri uri)
var request = (HttpWebRequest)WebRequest.Create(uri);
request.AllowAutoRedirect = true;
if (!string.IsNullOrEmpty(ClientSettings.ProxyServer))
var proxy = new WebProxy(ClientSettings.ProxyServer, ClientSettings.ProxyPort);
proxy.BypassProxyOnLocal = true;
proxy.Credentials = CredentialCache.DefaultCredentials;
request.Proxy = proxy;
return request;

For some reason, the “request.AllowAutoRedirect = true” is causing the first requests to fail with a “401: Unauthorized” from twitter!  No idea why that would happen, my suspicion is another little “gotcha” from CF.NET 2.0.

Any ideas?

Edit:  It looks like I jumped the gun and did just what everyone else does—blame Twitter’s issue on the client.  I’ve had a lot of reports that other twitter clients are experiencing the same issue.

1 comment:

Anonymous said...

When we expect to see a new version of Pocketwit?