简体   繁体   中英

Accessing Azure Mobile Service on Windows Phone from Different Projects

Hello I am having the following exception:

Additional information: The request could not be completed. (Bad Request)

I did not understand why since the function worked sometimes I therefore found the following on stackoverflow: MobileServiceInvalidOperationException When Trying To Retrieve Data From Azure . This issue unfortunately does not solve my issue.

The time is correct and I am using https connection. And all the communication is working perfectly. I however have divided my Windows Phone Silverlight application into several projects, the reason for this I have stated in another stackoverflow question: Deleting project/pages/usercontrols from memory .

The application flow is:

  • Project 1:

    1. Login (Authenticate the mobileservice)
    2. Navigate to Mainmenu, upon success.
    3. Service is contacted await MobileService.InvokeApiAsync<DTO.UserInfoDTO, DTO.UserInfoDTO>(UserInfoDTO); Success ALLWAYS!
    4. MobileService saved to resources Application.Current.Resources.Add("NavigationParam", App.MobileService); and Navigating to new project is done.
  • Project 2:
    1. Navigation parameter retrieved MobileService = MobileServiceClient)Application.Current.Resources["NavigationParam"]; (information seems intact when looking into the debugger).
    2. Service is contacted await MobileService.InvokeApiAsync<DTO.UserInfoDTO, DTO.UserInfoDTO>(UserInfoDTO); Success NEVER!

I know the packages are in order in Project 2 because I can upload information to blob storage and the includes are the same in both projects. But as soon as I contact my own backend service the application crashes with the above exception.

So can anyone help me with this issue, do I need to create a new mobileserviceclient and reauthenticate? Seems stupid?

I'm not sure what is going wrong, but generally, I would recommend making a new client instance here.

To avoid a login issue I would look at caching the mobile service's token. (See: http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-dotnet-how-to-use-client-library/#caching )

Then you can spin up a new client, reuse your existing auth tokens/etc, and continue on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM