简体   繁体   English

在MVC应用程序中使用Azure移动服务

[英]using azure mobile services with MVC application

I need to interact with my Azure Mobile API. 我需要与Azure移动API进行交互。 Upon login I get an authentication token that is sent with every request. 登录后,我得到一个随每个请求发送的身份验证令牌。 Adding Azure Mobile services to my MVC causes Html helpers to stop working. 将Azure移动服务添加到我的MVC中会导致HTML帮助程序停止工作。

How can I get around this? 我该如何解决? if it is not possible, can someone show me how to add an Header to an AJAX request for a Azure Mobile API request? 如果不可能,是否有人可以向我展示如何向Azure移动API请求的AJAX请求添加标头? And is it possible to pass the server response to my controller? 是否可以将服务器响应传递给我的控制器?

accessing the database without the API is not really a option. 在没有API的情况下访问数据库并不是真正的选择。 I have a client Xamarin Application that uses it. 我有一个使用它的客户端Xamarin应用程序。

OK, so I manage to work around my solution. 好的,所以我设法解决我的问题。

this link helped: http://developers.de/blogs/damir_dobric/archive/2014/04/29/consuming-azure-mobile-service-custom-api-with-net-backend.aspx 该链接有所帮助: http : //developers.de/blogs/damir_dobric/archive/2014/04/29/taking-azure-mobile-service-custom-api-with-net-backend.aspx

so basically this is how it works: Azure mobile library breaks any MVC project so it was uninstalled. 因此基本上是这样的:Azure移动库破坏了任何MVC项目,因此已将其卸载。

Include: Newtonsoft.Json this class is needed to map your response objects to whatever your classes look like. 包括: Newtonsoft.Json这个类是将您的响应对象映射到任何类所需要的。

Keep an close eye to what your uri looks like. 密切注意您的uri的外观。 Usually is something like https://Your-API-link.net/api/controller (remember that get requests have values added as part of the link and post as part of the header) I used JsonConvert.DeserializeObject<> for the response mapping 通常是类似https://Your-API-link.net/api/controller的东西(请记住,获取请求的值已添加为链接的一部分,而发布为标头的一部分),我使用JsonConvert.DeserializeObject<>进行响应映射

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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