سؤال

I've been having trouble querying a web server for information from my Windows Phone 7 app, and from my research, I've traced it back to MaxBufferSize/MaxReceivedMessageSize being too low. The problem is, I can't figure out how to change it. Every search result I find talks about the application being a WCF app, and to change the binding in ServiceReferences.ClientConfig. The solution from this post gives this example:

1. edit the ServiceReferences.ClientConfig to accept a large buffer.

 <binding name="BasicHttpBinding_MosaicService" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">  

However, I'm not using a WCF app, and I don't know what the equivalents of the above, and ServiceReferences.ClientConfig are for a regular WP7 application. Can anyone give me some help with this? I've done my best to figure it out myself but I'm getting nowhere.

For reference, in case someone else is having the problem I was (it took a really long time to figure out that this may be the problem), this is what is happening to me: I'm getting a WebException with the message: "The remote server returned an error: NotFound" thrown. And the relevant section of the stacktrace is:

at System.Net.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
هل كانت مفيدة؟

المحلول

I'm not sure how you went from the error message "The remote server returned an error: NotFound" to thinking that your client can't handle the size of the response. Much more likely, the error message is correct and the URL you are requesting can't be found. Drop a breakpoint in your code where you kick off the request. What is the RequestUri property set to on your HttpWebRequest object? Copy that URL into a browser and you'll more than likely see that you get a "page not found". Fix your incorrect URL and all will be well.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top