将Azure MobileServiceClient与本地后端连接

时间:2015-07-26 16:52:32

标签: javascript azure asp.net-web-api

我想调试WebApi客户端项目。

来自Azure的客户端示例 - 可以使用 - 。我通过更改

的行来配置它以使用我的本地WebAPI后端
var client = new WindowsAzure.MobileServiceClient('https://myproject-code.azurewebsites.net', 'https://someGateWay.azurewebsites.net', '');

var client = new WindowsAzure.MobileServiceClient('http://localhost:59477/', '', '');

如您所见,API在端口59477上运行。当我刷新客户端(端口4400)时,它会查询API并遇到CORS异常:

  

否'访问控制 - 允许 - 来源'标头出现在请求的资源上

如何将其设置为在本地开发和调试服务器和客户端?

1 个答案:

答案 0 :(得分:2)

我没有尝试过这个,因为我通常会将JavaScript后端用于我的移动应用程序,但您只需告诉移动应用程序允许localhost通过CORS访问它。这篇关于Azure Mobile Services .NET Adds CORS Support, Better Authentication的文章可以帮助你。

相关问题