[英]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 . 我不明白为什么,由于该功能有时起作用,因此有时会在stackoverflow上找到以下内容: 尝试从Azure检索数据时,出现MobileServiceInvalidOperationException 。 This issue unfortunately does not solve my issue.
不幸的是,这个问题不能解决我的问题。
The time is correct and I am using https connection. 时间是正确的,我正在使用https连接。 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 .
但是,我已将Windows Phone Silverlight应用程序划分为几个项目,我在另一个stackoverflow问题中提到的原因是: 从内存中删除项目/页面/用户控件 。
The application flow is: 申请流程为:
Project 1: 项目1:
await MobileService.InvokeApiAsync<DTO.UserInfoDTO, DTO.UserInfoDTO>(UserInfoDTO);
await MobileService.InvokeApiAsync<DTO.UserInfoDTO, DTO.UserInfoDTO>(UserInfoDTO);
Success ALLWAYS! Application.Current.Resources.Add("NavigationParam", App.MobileService);
Application.Current.Resources.Add("NavigationParam", App.MobileService);
and Navigating to new project is done. MobileService = MobileServiceClient)Application.Current.Resources["NavigationParam"];
MobileService = MobileServiceClient)Application.Current.Resources["NavigationParam"];
(information seems intact when looking into the debugger). await MobileService.InvokeApiAsync<DTO.UserInfoDTO, DTO.UserInfoDTO>(UserInfoDTO);
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. 我知道这些软件包在Project 2中是有序的,因为我可以将信息上传到Blob存储中,并且两个项目中的包含内容都相同。 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? 因此,有谁能帮助我解决这个问题,我是否需要创建一个新的mobileserviceclient并重新进行身份验证? 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 )
(请参阅: http : //azure.microsoft.com/zh-cn/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. 然后,您可以启动一个新客户端,重用您现有的身份验证令牌/等,然后继续。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.