I am trying to authenticate against the Huddle API using the Windows Phone 7 Emulator. However, I am not getting any success. I keep getting "The remote server returned an error: NotFound". I have even tried "dumbing down" my code and just trying a straight web site, eg. Google but still get the same result.
I have the following code:
string url = "http://www.google.com";
HttpWebRequest client= WebRequest.CreateHttp(new Uri(url)) as HttpWebRequest;
client.AllowReadStreamBuffering = true;
// Call and handle the response.
client.BeginGetResponse(
(asResult) =>
{
Dispatcher.BeginInvoke(
() =>
{
try
{
var response = client.EndGetResponse(asResult);
System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
string responseString = reader.ReadToEnd();
}
catch (WebException failure)
{
throw failure;
}
});
},
null
);
Execution always ends up in the catch section. However, having watched Fiddler2, there seems not to be any traffic at all to google.com. So the request doesn't seem to be being made.
I've seen a similar problem here Retrieve XML from https using WebClient/HttpWebRequest - WP7, but I am using a standard port so not sure this is relevant. I have also tried simplifying the code as per the post, but no success.
Interestingly, the most likely option seems to be because I may not have Network Capabilities defined in my AppManifestWM.xaml file as per HttpWebRequest Breaks On WP7, but my AppManifestWM.xaml file appears to have this defined:
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
<App xmlns="" ProductID="{ac5b5d62-573c-4134-b290-0ad4f678ad7f}" Title="xxx.WindowsPhone7.Client" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="xxx.WindowsPhone7.Client author" Description="Sample description" Publisher="xxx.WindowsPhone7.Client publisher">
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_LOCATION" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_MICROPHONE" />
<Capability Name="ID_CAP_MEDIALIB" />
<Capability Name="ID_CAP_GAMERSERVICES" />
<Capability Name="ID_CAP_PHONEDIALER" />
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
</Capabilities>
<Tasks>
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
</Tasks>
<Tokens>
<PrimaryToken TokenID="xxx.WindowsPhone7.ClientToken" TaskName="_default">
<TemplateType5>
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
<Count>0</Count>
<Title>xxx.WindowsPhone7.Client</Title>
</TemplateType5>
</PrimaryToken>
</Tokens>
</App>
</Deployment>
So I'm at a loss. The request doesn't actually seem to be occurring, leading me to think something is preventing it.
Update:
Nothing changed, but thought this stack trace might heko:
System.Net.WebException was unhandled Message=The remote server returned an error: NotFound. StackTrace: at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at xxx.WindowsPhone7.Client.Views.AddHuddleUserPage.<>c__DisplayClass2.<>c__DisplayClass4.b__1() at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at System.Delegate.DynamicInvokeOne(Object[] args) at System.MulticastDelegate.DynamicInvokeImpl(Object[] args) at System.Delegate.DynamicInvoke(Object[] args) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority) at System.Windows.Threading.Dispatcher.OnInvoke(Object context) at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args) at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args) at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
The status is System.Net.WebExceptionStatus.UnknownError
Thanks for your time.